Speeding up array initialization

Geoff Canyon gcanyon at inspiredlogic.com
Sat Nov 22 17:36:44 EST 2003

First, remember that you don't have to initialize an array unless you 
have values you want in it. Without initializing anything,

put x[1,2] into y

is perfectly fine, and results in y containing empty.

In the case you listed below, what you want is something like this:

1,1 a
1,2 b
1,3 c
1,4 d
1,5 e
2,1 f
2,2 g
2,3 h
2,4 i
2,5 j

In the above the separator is a space, for ease of use in email. You 
need to use something that is guaranteed not to be in your index or 

Given the above in a variable x,

split x using return and space

would give you the array you want.

So now you just need a way to go from the lines you have to the 
information above. Something like this will work:

   put empty into tNewData
   put 0 into tLineCounter
   repeat for each line L in tData
     add 1 to tLineCounter
     put 0 into tItemCounter
     repeat for each item T in L
       add 1 to tItemCounter
       put tLineCounter,tItemCounter && T & cr after tNewData
     end repeat
   end repeat


Geoff Canyon
gcanyon at inspiredlogic.com

On Nov 22, 2003, at 1:49 PM, jbv wrote:

>> You can change your delimiters in the split, JB.  (The second cannot 
>> be
>> null, though.)  Build your value to be split appropriately.
> Well, thanks for the advice, but I've already tried the split cmd in 
> many
> ways, but with no success...
> Here's an example :
> I have a variable S made of 2 lines of 5 items each :
>     line 1 :    a,b,c,d,e
>     line 2 :    f,g,h,i,j
> how do I use the split cmd so that I get a 2 dimensions array S in 
> which :
>     S[1,1] = a
>     S[1,2] = b
>     S[2,1] = f
>     S[2,2] = g
> and so on...
> Thanks,
> JB
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution

More information about the Use-livecode mailing list