returning result from a function when the number of items in the result varies
stephenREVOLUTION2 at barncard.com
Sun Sep 21 11:29:40 CDT 2008
It's not a list! It's an array.
It's not THE NUMBER OF LINES in myArray.
it's the number of lines in the KEYS of myArray. Big difference.
I'll build a silly array here:
set the itemdelimiter to comma
put "Jefferson,Washington,Lincoln,Bush,Elvis" into historyList
repeat with n = 1 to number of items in historyList
put item n of historyList into myArray[n]
Same as :
1) put the keys of myarray into tKeys
2) put number of lines in temp into tArrayLines
Once again, you can't directly put an array into a field to "see" the
elements. It needs to be 'disassembled', element by element This is
expected behavior. You make a list by rotating through each key,
put myArray  & return into toadMeatList
put myArray  & return after toadMeatList
put myArray  after toadMeatList
or in a "regular" loop
put "1,2,5" into orderList
repeat with n = 1 to numLines
put myArray[n] & return after toadMeatList
or using combine
combine myArray with return & tab
>From: "william humphrey" <shoreagent at gmail.com>
>To: "How to use Revolution" <use-revolution at lists.runrev.com>
>Subject: Re: returning result from a function when the number of items in
> the result varies
>Thanks again. I'm still curious about the array. When I use the "number of
>lines in myArray" I get the correct answer "1" before I send it out of the
>function as "myArray" but when I do the same "number of lines in myArray"
>after it is called then the answer is "0".
>If I ask for one key in the array (as myArray ) and return that it works
>as expected. I understand that the contents of the array are invisible until
>I ask for one of the keys. But it still wasn't working as expected. I think
>Jim's suggestion might be better as the list of data elements can be handed
>back and it will work as I expect.
>It was fun to play with the array and I'm surprised that it doesn't return
>in the function like a list would as in my mind I think of the array
>as a list.
s a n f r a n c i s c o
- - - - - - - - - - - -
More information about the use-livecode