Can Custom Functions Return Arrays?

Mark Smith mark at maseurope.net
Thu Jul 19 15:29:57 EDT 2007


On 19 Jul 2007, at 20:06, Dave Cragg wrote:

>
> On 19 Jul 2007, at 19:31, Gregory Lypny wrote:
>
>> So, is it that Revolution custom functions cannot return arrays or  
>> am I doing something wrong?
>
>
> Right. But you can pass in a reference to an array as a function  
> argument, which may help you.
>

This is news to me! Put this in a button script:

on mouseUp
   put getArray() into tArray
   combine tArray by cr and "="
   put tArray
end mouseUp

function getArray
   repeat with n = 1 to 10
     put "this is in an array" into tArray[n]
   end repeat
   return tArray
end getArray

This works perfectly on my machine - what happens on yours?

What you can't do is use a function that returns an array as a  
parameter to another handler:

get someFunction(getArray())

and you can't use an array in a "do" statement:

do "someCommand someArray"

Many (perhaps most) of my apps rely on functions that return arrays....

Best,

Mark



More information about the use-livecode mailing list