BPorter
04-14-2007, 03:41 AM
Hi,
global proc createNewCamMenu ()
{
string $unknown = "unknown";
string $test = `whatIs "$a"`;
if (`size($test)` == `size($unknown)`)
{
global int $a = 2;
}
optionMenu
-parent intCol1
-label ("Camera" + $a)
("camDropMenu" + $a);
$a++;
string $cams[] = `listCameras`;
for ($each in $cams)
menuItem -label $each ($each + " MenuItem");
}
I am trying to create the variable $a once so every time the proc is called, it doesn't recreate it and make it 0. The point of the proc is to create a new option menu with all the cameras in it. The name of the first one would be "camDropMenu", the 2nd "camDropMenu1" , 3rd "camDropMenu2" and so on and so forth. I am aware that I can not specify a name for the option menu's and just use the default one that Maya gives, but that is poor scripting and not disciplined. My syntax works until I try to store the proc into memory. It says $a is not declared, but if you run the conditonal by itself, it works fine. Any help would be appreciated as this is my first script. Thanks
global proc createNewCamMenu ()
{
string $unknown = "unknown";
string $test = `whatIs "$a"`;
if (`size($test)` == `size($unknown)`)
{
global int $a = 2;
}
optionMenu
-parent intCol1
-label ("Camera" + $a)
("camDropMenu" + $a);
$a++;
string $cams[] = `listCameras`;
for ($each in $cams)
menuItem -label $each ($each + " MenuItem");
}
I am trying to create the variable $a once so every time the proc is called, it doesn't recreate it and make it 0. The point of the proc is to create a new option menu with all the cameras in it. The name of the first one would be "camDropMenu", the 2nd "camDropMenu1" , 3rd "camDropMenu2" and so on and so forth. I am aware that I can not specify a name for the option menu's and just use the default one that Maya gives, but that is poor scripting and not disciplined. My syntax works until I try to store the proc into memory. It says $a is not declared, but if you run the conditonal by itself, it works fine. Any help would be appreciated as this is my first script. Thanks
