View Full Version : About to lose my mind... pass variable from textField?

09 September 2005, 08:57 PM
Sorry to keep posting inane questions... I've been given the task of writing a number of scripts at work because the normal script guy is too busy, and this has consumed my while weekend!

What I need to do is extremely simple, but after hours of web searching, I can't find a way to do it.

I have a textField where you type in a file path. When you hit enter (or preferrably -changeCommand), I want a global variable to be handed the contents of that textField. Could someone please post a simple example of making a text field that passes its contents to a global variable?

I looked here, but even his script doesn't do what it's supposed to:

Here's an excerpt of what I've got, that's totally not working..

//initialize controller name input
string $p2e_ctrlText = `text -label "controller name:"`;
string $p2e_ctrlMainName = `textField -editable true`;
textField -edit -enterCommand ("changeVariable("+$p2e_ctrlMainName+")") $p2e_ctrlMainName;

At least this doesn't complain about undeclared variables, but no matter what, it never calls the changeVariable proc. I can hit enter all day long on that text field, but nothing ever happens...

Any help would be greatly appreciated, because I have to go back to work tomorrow with something that works!!


09 September 2005, 05:42 AM
I think your doing this wrong--forget the global variable--make a proc that runs when you need the path--not when its entered==make sure your textfield is named...

proc string getTextfieldData()
string $filePath= `textField -q -tx "textFieldName`
return $filePath;

If your textfield window closes--uses visability instead of close or write your path to
an ascii

...but you could make it global on entry if you wanted to...

proc textfieldEntryToGlobalVar()
global string $filePath;
$filePath= `textField -q -tx "textFieldName`;

CGTalk Moderation
09 September 2005, 05:42 AM
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.