seb4d
06-07-2004, 01:46 PM
Hi !
I am a beginner in scripting, I have no background at all in programming either.
I'm learning Mel script with Wilkins ' book but there is something I don't understand.
I am writing a simple script that creates a custom window, asks for a number of spheres to create, and creates those spheres when you hit a button.
My problem is that the button's -command flag doesn't execute the procedure I wrote that creates the spheres.
Could someone explain to me why this happens ? And what error did I make ?
Thank you in advance !
Here is the script :
//create a window
window -title "Create spheres" -rtf true ;
columnLayout;
//radio buttons to chose how many
//spheres you want to create
radioButtonGrp -numberOfRadioButtons 4
-label "How many spheres ?"
-labelArray4 "1" "2" "3" "4"
-select 1
buttons;
//query the radioButtonGrp and assign result to a variable
string $choice = `radioButtonGrp -query -select buttons`;
//procedure that creates the spheres
proc creation()
{
string $choice;
switch ($choice)
{
case "1":
sphere;
break;
case "2":
sphere ; sphere ; move 0 3 0 ;
break;
case "3":
sphere ; sphere ; move 0 3 0 ; sphere ; move 0 6 0;
break;
case "4":
sphere ; sphere ; move 0 3 0 ; sphere ; move 0 6 0 ; sphere ; move 0 9 0;
break;
}
}
//creation button
button -label "create !"
-command "creation()";
//display the window
showWindow
I am a beginner in scripting, I have no background at all in programming either.
I'm learning Mel script with Wilkins ' book but there is something I don't understand.
I am writing a simple script that creates a custom window, asks for a number of spheres to create, and creates those spheres when you hit a button.
My problem is that the button's -command flag doesn't execute the procedure I wrote that creates the spheres.
Could someone explain to me why this happens ? And what error did I make ?
Thank you in advance !
Here is the script :
//create a window
window -title "Create spheres" -rtf true ;
columnLayout;
//radio buttons to chose how many
//spheres you want to create
radioButtonGrp -numberOfRadioButtons 4
-label "How many spheres ?"
-labelArray4 "1" "2" "3" "4"
-select 1
buttons;
//query the radioButtonGrp and assign result to a variable
string $choice = `radioButtonGrp -query -select buttons`;
//procedure that creates the spheres
proc creation()
{
string $choice;
switch ($choice)
{
case "1":
sphere;
break;
case "2":
sphere ; sphere ; move 0 3 0 ;
break;
case "3":
sphere ; sphere ; move 0 3 0 ; sphere ; move 0 6 0;
break;
case "4":
sphere ; sphere ; move 0 3 0 ; sphere ; move 0 6 0 ; sphere ; move 0 9 0;
break;
}
}
//creation button
button -label "create !"
-command "creation()";
//display the window
showWindow
