PDA

View Full Version : Simply rename window


safakoner
12-09-2003, 09:19 AM
I tyr to write a simply rename window. like this;

global string $sel[];
global string $newName;
window;
columnLayout ;
global string $sel[];
global string $newName;
string $sel[]=`ls -sl`;
textField -editable true -text $newName ;
button -c "doit";
setParent;
showWindow;

global proc doit()
{
global string $sel[];
global string $newName;
rename $sel $newName;
}

When I click do it an error displayed.
"New name has no legal characters."

What is this ?
Thanks

Doogie
12-09-2003, 03:58 PM
hmm, you announced "global string $sel[] and $newName" three times. You only really need it once... and Id use hesitation using the global part.

When you write "textField -editable true -text $newName ;", -text changes the default text written in the box, not a query of the box. Id suggest querying the box (seen below) when you need the value, because it may change between the time you open the window and when you need it.

I also suggest you pass variables to the procedure as you need them, to make sure you know what the content of the veriable is at that time.

one note, you can use "print $var" as a test at any time to find out what the variable's value currently is.

Here's my version:
proc mainWin()
{
string $sel[];
window;
columnLayout ;
string $sel[]=`ls -sl`;
textField -editable true renameText;
button -c "doit($sel[0])" button;
setParent;
showWindow;
}

proc doit(string $sel)
{
rename $sel `textField -q -tx renameText`;
}

mainWin();

safakoner
12-10-2003, 07:31 AM
hmmmm.. now I understand :bounce:
this is funny
thanks for your help

CGTalk Moderation
01-16-2006, 08:00 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.