Create array with variables

Dave Cragg dcragg at lacscentre.co.uk
Sun Aug 24 12:23:01 EDT 2003


At 5:58 pm +0200 24/8/03, Ludovic Thébault wrote:
>Hello
>
>I have made a 8x8 grid with fields.
>I've named these fields like a spreadsheet (A1, B1.. A2, B2..)
>Each field have a random value.
>I want to create arrays to works with these values, but this script
>doesn't works :
>
>repeat with n=1 to 64
>put fld n into ("array"&char 1 of the short name of  fld n)[char 2 of
>the short name of  fld n]
>end repeat
>
>How do this ? Thanks.

It may not be what you want, but I think this would be better:

repeat with n=1 to 64
   put fld n into tArray[the short name of field n]
end repeat

This will give array keys that match the field names.

However, if you ever change the layers of the 
fields, you'll have trouble, so how about this:

repeat for each char k in "ABCDEFGH"
   repeat for each char i in "12345678"
     put field (k & i) into tArray[k & i]
   end repeat
end repeat

Cheers
Dave



More information about the use-livecode mailing list