Mel passing textFieldGrp text to proc

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  04 April 2013
Mel passing textFieldGrp text to proc

Hey guys and gals,

I am wrote a script that creates a hirarch of groups and want to add a UI that lets the user enter a name for the groups. I don't understand how to geht the test out of my textfield though. The name of the thextfield is passed on the the second procedure correctly but i allway get an error. I am sure the solution is quite simple, I can't figure it out myself though. I'd appreciate if someone coule help me.

global proc jl_groupHirarchyUi ()
//create window
$win = "jl_groupHirarchyUI";
if (`window -exists $win`)
deleteUI $win;
window -title "Named Group Hirarchy" $win;
columnLayout -adj true;
//save name of textfield to variable
$textFieldName = `textFieldGrp -l "Character Name:" -text "Editable"`;

//create button with function
$button = `button -l "Go" -c ("checkText\" "+$textFieldName+"\"")`;

showWindow $win;

global proc checkText (string $cN)
// get the results
string $charName;
print ("\n$cN is: " + $cN + "\n");
$charName = `textFieldGrp -q -tx $cN`;

//execute procedure that creates group hirarchy
$cmd = ("jl_groupHirarchy");
evalEcho $cmd;

  04 April 2013
There is a little error in line 13. It would also be better to get used to declare variables specifying their types.
  04 April 2013
Thanks zaskar,

I got most of the code from ohter scripts.I'm guessing ("checkText\" "+$textFieldName+"\"")`; ist the part that has the error in it but I honestly don't understand that part at all.
  04 April 2013
What makes me wonder the most is the fact that the script works. even when I hit the button it prints out the correct name of the thextfield I am tryint to read. I just get // Error: file: C:/Users/.../Documents/maya/2012-x64/prefs/scripts/jl_groupHirarchyUi.mel line 34: Object ' jl_groupHirarchyUI|columnLayout3|textFieldGrp3' not found. / as an error.
  04 April 2013
That part is simply a procedure call:
checkText "controlFieldName"

but having the control field name inside a string and to hand it over as argument, the procedure call itself has to be a string and it gets:
("checkText \"" + $controlField + "\"");

although if maya knows that the procedure "checkText" receives a string you wouldnt need such a stunt and you can omit the quotation marks:
("checkText " + $controlField);

As you see if you want to put quotation marks into a string you need to use a backslash
string $str = "\"";

now find the error
  04 April 2013
I kinda get it but not really . It's working though. THX zaskar.
  04 April 2013
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 11:38 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.