Page 1 of 1

Array Variables

Posted: Wed Mar 21, 2012 5:38 pm
by Christopher Kernahan
I'm not sure if this has been covered before; I did search the Forum.

I used the below code to construct an "Array" in TM1. Each run of the While loop takes the variable and adds another value onto it, delimiting it with a ';' to identify the join. The second While loop deconstructs the array.

It was useful for my purposes but I haven't tested the performance or other (ie character?) limitations of this method.

Code: Select all


iCount = 0;
iLimit = 10;
vArray = '';

WHILE( iCount < iLimit);

             vValue = Some Calculation or String Manipulation;
         
             vArray = vArray | vValue | ';'  ;

             iCount = iCount + 1;

END;

iCount = 0;
iLimit = 10;

WHILE( iCount < iLimit);

              vValue = SUBST( vArray, 1, SCAN( ';', vArray) - 1);

              vArray = DELET( vArray, 1, SCAN( ';', vArray));

              iCount = iCount + 1;

END;

Re: Array Variables

Posted: Thu Mar 22, 2012 1:03 pm
by Duncan P
Have a look here

http://www.tm1forum.com/viewtopic.php?p=27954

The answer is that if you are doing this for small numbers of items (e.g. TI variables) it's fine. If you get into the thousands (e.g. items of a dimension) it is a very bad idea.