View Full Version : how to declare a matrix with 2 argument

10-09-2005, 05:48 AM
The size of a 2D array matrix must specify when create it :

matrix $a3[2][3];
matrix $a2[][]; // ERROR: Size not specified

I tried to declare a matrix with 2 argument :

matrix $a3[$a][$b]; //Syntax error

so I tried any other way :

int $a=2,$b=3;
eval ( "matrix $a3["+$a+"]["+$b+"];" );
print $a3[0][0];
// Error: print $rdx[0][0]; //
// Error: Line 3.16: "$a3" is an undeclared variable. //

anyone can help me? thanks.

10-10-2005, 04:36 PM
int $x = 3 ;
int $y = 5 ;

string $trickMaya = ("matrix $m[" + $x + "][" + $y + "];") ;
eval $trickMaya ;

//$m is your variable-sized matrix

Your script fails because you do an eval without capturing the result of your eval...which happens to be your variable-sized matrix ;)


05-09-2006, 03:40 PM
int $x = 3 ;
int $y = 5 ;

string $trickMaya = ("matrix $m[" + $x + "][" + $y + "];") ;
eval $trickMaya ;

this doesn't work within a proc ! I can't use $m there maya says:
// Error: "$m" is an undeclared variable. //

How can I make this work within a proc(){}

05-09-2006, 03:42 PM
how can i make this work within a proc?

Maya says undeclared variable!

05-09-2006, 03:47 PM
how could i get this work within a proc???

maya says that $m is an undeclared variable

05-09-2006, 04:27 PM
I really can't understand what you're doing wrong here.
Either your last workaround or harmless's way works perfectly well for me.
The $m or $a3 variables are being declared as soon as the eval command is being called.

Maybe you can post a larger portion of your script so we can have a better look

CGTalk Moderation
05-09-2006, 04:27 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.