returning result from a function when the number of items in the result varies
Jim Ault
JimAultWins at yahoo.com
Sun Sep 21 02:21:57 EDT 2008
If there is no real reason to use an array in the function, then I would
avoid it since your function may generate two 'hits' that happen to have the
same key. In that case, only one answer will be returned since keys have to
be unique.
If you are transferring simple data, why not use the standard format of
put empty into rtnString
repeat for each
--your code here
put dataElement & tab & identifier & cr after rtnString
end repeat
filter rtnString without empty
if rtnString is empty then put "no data -- no identifier" into rtnString
return rtnString
then in the main handler you have a list that will be something like
dataElement identifier
dataElement identifier
dataElement identifier
and dataElements can have the same value without data loss.
Don't get me wrong, I use arrays every day, but the simple solutions seems
to be more appropriate here.
Hope this helps
Jim Ault
Las Vegas
On 9/20/08 7:20 PM, "william humphrey" <shoreagent at gmail.com> wrote:
> 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.
>
>
>
More information about the use-livecode
mailing list