# Passing var to matrix dimensions

**URL:** https://forum.highend3d.com/t/passing-var-to-matrix-dimensions/5298
**Category:** Maya
**Tags:** mel
**Created:** [May 13, 2003, 12:23am UTC](https://forum.highend3d.com/t/passing-var-to-matrix-dimensions/5298 "2003-05-13T00:23:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![chet](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/c/9dc877/32.png) [@chet](https://forum.highend3d.com/u/chet)
#### Post date: [May 13, 2003, 12:23am UTC](https://forum.highend3d.com/t/passing-var-to-matrix-dimensions/5298/1 "2003-05-13T00:23:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jamesj](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/85f322/32.png) [@jamesj](https://forum.highend3d.com/u/jamesj)
#### Post date: [May 13, 2003, 3:19am UTC](https://forum.highend3d.com/t/passing-var-to-matrix-dimensions/5298/2 "2003-05-13T03:19:22Z")

</div>

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
