Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   passing variables to a proc (https://simplymaya.com/forum/showthread.php?t=8728)

nspiratn 02-11-2003 08:50 AM

passing variables to a proc
 
I'm trying to pass the objectname of the radioButtonGrp to the myProc procedure. But I keep getting an error that $rButton is an undeclared variable. What am I doing wrong?

global proc myProc(string $rButton)
{
string $rButton;
int $nameButton;
$nameButton = `radioButtonGrp -q -sl $rButton`;
print $nameButton;
}

global proc TestGUIscript()
{
string $rButton;
string $window = `window -wh 400 500 -title "Radio Test"`;
rowLayout -nc 3;
text " ";
$rButton = `radioButtonGrp -numberOfRadioButtons 2 -label1 "Hierarchical" -label2 "Alphabetical"`;
print $rButton;
radioButtonGrp -edit -onCommand "myProc($rButton)" $rButton;
showWindow $window;
}

Thanks.

kbrown 02-11-2003 12:33 PM

First of all, I usually give controls names rather than rely on the ones that maya assigns. Makes life a lot easier :)

Anyway, in your myProc you have defined $rButton twice. Also you're missing some parenthesis and whatnot in your radioButtonGrp -edit line...

This should work:
Code:

global proc myProc(string $rButton)
{
        int $nameButton;
        $nameButton = `radioButtonGrp -q -sl $rButton`;
        print $nameButton;
}

global proc TestGUIscript()
{
        string $rButton;
        string $window = `window -wh 400 500 -title "Radio Test"`;
        rowLayout -nc 3;
        text " ";
        $rButton = `radioButtonGrp -numberOfRadioButtons 2 -label1 "Hierarchical" -label2 "Alphabetical"`;
        radioButtonGrp -edit -onCommand ("myProc(\"" + $rButton + "\")") $rButton;
        showWindow $window;
}


nspiratn 02-11-2003 12:41 PM

COOL! Thanks a lot :)

YAAAAAAAY!


All times are GMT. The time now is 07:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018