PDA

View Full Version : Syntax Error about parsing arguements ????


ScottyDoesntKnow
02-13-2006, 06:17 PM
ok I'm just playing around with Mel lately and made up this code.

window -rtf -title "The Window" myWindow;

button -c createBalls -label "Create" cButton;

showWindow myWindow;

proc createBalls ( ) {
int $c = 0;
while ( $c <= 15){
sphere;
move rand(10) rand(10) rand(10);
scale rand(3) rand(3) rand(3);
$c++;
}
}

and i get this error message in the script editor

// Error: Error while parsing arguments. //

what did i do wrong?

mhovland
02-13-2006, 06:41 PM
Your error is in line 1,

window -rtf -title "The Window" myWindow;

You have added the -rtf flag, which takes a boolean as its' argument. You have no value for -rtf. If you change your code to be:

window -rtf 0 -title "The Window" myWindow;

or

window -rtf 1 -title "The Window" myWindow;

That line will be fixed, but you will end up with a new error:

// Error: line 3: Controls must have a layout. No layout found in window : myWindow //

All windows must have a layout to hold the controls. If you change your code to below, your window code will work:

window -rtf 0 -title "The Window" myWindow;
columnLayout;
button -c createBalls -label "Create" cButton;

showWindow myWindow;

Next, what you will find, is that there is no code to remove the window if it already exists, and you will throw another error:

// Error: line 1: Object's name is not unique: myWindow //

You need to add this code to the begining of the script:

if(`window -exists myWindow`)
deleteUI -window myWindow;


This will delete any instance of the window that already exists. It is a good habit to get into to always write the code to delete the window if it exists, any time you are going to script a window.

Once that is done, you will throw this error:

// Error: line 11: Invalid argument: rand //

This error is because of order of operation. Your rand calls need to execute and then use the resulting values in the move and scale operations.

Here is the fixed up code:


if(`window -exists myWindow`)
deleteUI -window myWindow;

window -rtf 0 -title "The Window" myWindow;
columnLayout;
button -c createBalls -label "Create" cButton;

showWindow myWindow;

proc createBalls ( ) {
int $c = 0;
while ( $c <= 15){
sphere;
move (rand(10)) (rand(10)) (rand(10));
scale (rand(3)) (rand(3)) (rand(3));
$c++;
}
}



I hope all my explainations were clear, if you have any more questions, fire away.

ScottyDoesntKnow
02-13-2006, 06:52 PM
wow um... Thanks. Ok Im definately going to go read more. But thanks again. :thumbsup:

CGTalk Moderation
02-13-2006, 06:52 PM
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.