Array question

Mark Brownell gizmotron at earthlink.net
Mon Mar 22 17:41:38 EST 2004


On Monday, March 22, 2004, at 02:04  PM, Glen Bojsza wrote:

> Example, the user wants the array from 3 through 7.
>
> This can be done using repeat loops but can it be done using a single 
> line command?
>
> thanks,
>
> Glen

You could create a function that does it for you, that could get the 
data in 3 through 7 of your larger array and package it just the way 
you need it when the function returns it.

Warning: untested handler

Example:
put getSpotAtoSpotB(myArray, 3, 7) into rackOfData1

function getSpotAtoSpotB tArray startSpot endSpot
    put "" into zap
    repeat with i = startSpot to endSpot
       put tArray[i] & "," after zap
    end repeat
    return zap
end getSpotAtoSpotB

So this way you can add the functionality you need to your own code. 
You can have one line return four items of a middle section of an array.

I can't remember if you have to use the actual array as a global 
instead of passing it as a property of the function. If that is the 
case then just declare the array a global and use it instead of tArray 
with "function getSpotAtoSpotB startSpot endSpot."

Mark




More information about the use-livecode mailing list