SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / passing variables to a proc
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 02-11-2003, 07:50 AM   #1
nspiratn
Registered User
 
nspiratn's Avatar
 
Join Date: Dec 2002
Location: CA
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
__________________
~nspiratn
nspiratn is offline   Reply With Quote
Old 02-11-2003, 11:33 AM   #2
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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;
}
__________________
Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
kbrown is offline   Reply With Quote
Old 02-11-2003, 11:41 AM   #3
nspiratn
Registered User
 
nspiratn's Avatar
 
Join Date: Dec 2002
Location: CA
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
Default

COOL! Thanks a lot

YAAAAAAAY!
__________________
~nspiratn
nspiratn is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

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

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.