View Full Version : need somthing like a global dynamic array...

07 July 2007, 12:54 PM
Hi everyone, I'm having a problem.
I want to store the names of locators in a string array. The locators are created by clicking in the viewport - I used a draggerContext to get the coordinates of the mouse.
The problem is, where do I store the names of the created locators to use them later in an other part of the script? Global variables have to have a constant value and a local variable in the sampleContextPress-function would be recreated each time of execution.
so i cant use something like:
string $locAr[];
$locAr[size($locAr)] = `spaceLocator`;

proc sampleContextPress(){
float $pressPosition[] = `draggerContext -q -anchorPoint sampleContext`;

spaceLocator; //right now the names are not stored

move -ws $pressPosition[0] $pressPosition[1] $pressPosition[2];

if ( `contextInfo -ex sampleContext` )
deleteUI -tc sampleContext;

-pressCommand "sampleContextPress"
-cursor "hand"
-space "world"
setToolTo sampleContext;

Many thanks for your help!

07 July 2007, 02:37 PM
Initialization of a global has to be done with a constant but the global itself doesn't have to be constant.

i.e. you can't do this:

global proc testit()
global string $s[] = `ls -sl`;

...but you can do this:

global proc testit()
global string $s[];
$s = `ls -sl`;

07 July 2007, 03:24 PM
oh easy ;) thank you!!

CGTalk Moderation
07 July 2007, 03:24 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.