Passing var to matrix dimensions

I thought this would be a simple exercise but apparently not.

consider the following:

I am trying to pass dimensions to a matrix

int $a = 3;
int $b = 4;

matrix $foo[$a][$b];

it seems straightforward but it gives me a syntax error.

I tried a more round about approach:

int $a = 3;
int $b = 4;

string $bar = ("matrix $foo[" + $a + "][" + $b +"]";
eval ($bar);

This works fine interactively but when I source the script it says $foo is an undeclared variable

The intention is to capture [frame][particle] id for some file translation. I know it is possible with arrays. But it can be cumbersome. The problem is that matrices need an explicit declaration of dimension. I want to be able to pass ($start-$end) and (particle.count) to the declaration.

Any thoughts?

thanks

cl

you can have the proc that you've written, return a string that can be evaluated in your main proc.

here is an example

proc string matrixName(){
int $a = 3;
int $b = 4;
string $bar = ("matrix $foo[" + $a + "][" + $b + "]");
return $bar;
}

// main
global proc matrixPop(){
string $dog = matrixName;
evalEcho($dog);
}
// end

-I hope this helps
-james