PDA

View Full Version : query text in a textField


pbarnes
02-07-2009, 10:31 PM
i have a textField and want to query the txt to use as a new name

//naming bricks
text -l "Rename Bricks";
textField "brickName";
button -l "Rename Wall" -c renameBrick;
//textField for new name

proc renameBrick()
{
$newName = `textField -q -tx brickName`;
// but how do i set var $newName to be the text from the field
// this just says no object matches name

string $renameSet[] = `ls ls "offsetBrick*" "brick*"`;

size($renameSet);

for ($i=0; $i <= `size($renameSet)`; $i++)
{
$i = 0;
$brickNumber = $i+1;
rename $renameSet[$i] ($newName + "$brickNumber");
}
}


but it doesnt
just says no object matches name
cheers

wigal
02-08-2009, 11:17 AM
proc renameBrick()
{
$newName = `textField -q -tx brickName`;
// but how do i set var $newName to be the text from the field
// this just says no object matches name

string $renameSet[] = `ls -tr "offsetBrick*" "brick*"`;
int $size = `size($renameSet)`;
for ($i=0; $i < $size; $i++)
{
rename $renameSet[$i] ($newName + "_" + ($i+1));
}
}

edit: sorry for the edit...

there seemed to be a problem when the array was listing the shapes and the transforms...when the script renames the transform the shape gets renamed automatically which stops the script... listing only the transforms works... also you had ls twice... hope that helps...

ps: i added the _ between the new name and the numbering.. makes it better to read in my opinion.. but maybe thats not what you want..

pbarnes
02-08-2009, 02:44 PM
cheers that works a treat

if i used my orig code and changed the ls command to yours but left the rest the same, how comes it still doesnt work?
just curious

cheers

wigal
02-08-2009, 03:03 PM
it's the <= in your loop... since there are only one less than the size there... when its looking for the = amount it cannot find it.
Also you are setting $i =0 in the loop... which means its is always checking for 0

and you need to loose the quotation marks around $brickNumber....

pbarnes
02-08-2009, 03:13 PM
cheers for the explanation

i thought i needed the quotations as for concatenation of the two string as they are two different types one being text the other numerical values

CGTalk Moderation
02-08-2009, 03:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.