returning result from a function when the number of items in the result varies

Stephen Barncard stephenREVOLUTION2 at barncard.com
Sat Sep 20 22:38:09 EDT 2008


HEY! that's not fair to the arrays. :) They REALLY are useful and amazing.

Honestly,  once you have you're aha moment you'll understand it.

Your code is working as expected. For now, Just imagine the array to 
be a package of little ordinary variables that can be easily 
manipulated.

put array into fld "output"    -- won't be seen

You can't "see" an array when "put" it - it's still there
but you can't put it into anything except another array (or save it 
as a custom property)

put array into array2
set the customproperty[myarray]  of this stack to array

If you want to see the elements you gotta take it apart.

combine does that.

combine with return and tab

which turns the array into a single text string

or the

  repeat for each line tKey in the keys of array

put tKey & return after tOut
end repeat

put tOut


>for some reason in my function if I say
>
>return myArray then I get an array with zero lines even when that is not
>true.
>
>
>If I say return myArray[1]  (where 1 is one of the keys which has data in
>the array) then it does return that correctly but just with that one line of
>course.
>
>
>This is why I hate arrays. It is not working like I expected.
>
>On 9/20/08, william humphrey <shoreagent at gmail.com> wrote:
>>
>>  Thanks for not only answering but giving me the example. The repeat for
>  > each line in the array will work perfectly.
>

-- 


stephen barncard
s a n  f r a n c i s c o
- - -  - - - - - - - - -





More information about the use-livecode mailing list