array: can it be returned by a function?

David Vaughan dvk at dvkconsult.com.au
Mon Nov 25 22:31:01 EST 2002


On Tuesday, Nov 26, 2002, at 13:01 Australia/Sydney, Oliver Hardt wrote:

> hi david:  here is the code that doesn't work.  the function is called 
> from handlers with a tab-separated list of values (the data for the 
> array and the keys).  when i trace the function, the local var 
> lPPArray appears to be doing fine, however, the calling handler 
> doesn't get the array back.  perhaps you could try this out and see 
> whether it works ... thanks a lot!  olli.
>
> -- this function gets a tab-separated list of
> -- values (ppData) and a tab-separated list of
> -- keys (ppKeys).  then an array is filled up
> -- with the ppData values and returned
>
> function gF_LoadPPRec pData,pKeys
>   put empty into lPPArray
>   set the itemDelimiter to tab
>   repeat with i = 1 to the number of items of pKeys
>     put item i of pData into lPPArray[(item i of pKeys)]
>   end repeat
>
>   return lPPArray
> end gF_LoadPPRec

Oliver

I wrote this:
on mouseUp
   put 1 & tab & 2 & tab & 3 & tab & 4 into pKeys
   put "Freddo" & tab & "Frog" & tab & "was" & tab & "here" into pData
   get gf_LoadPPRec(pData,pKeys)
   combine it with return and comma
   put it into field "f2"
end mouseUp

function gF_LoadPPRec pData,pKeys
   put empty into lPPArray
   set the itemDelimiter to tab
   repeat with i = 1 to the number of items of pKeys
     put item i of pData into lPPArray[(item i of pKeys)]
   end repeat
   return lPPArray
end gF_LoadPPRec

which you can see includes your untouched function. It simply exercises 
it; and it worked perfectly, producing:
1,Freddo
2,Frog
3,was
4,here
from that input data.

Something else is the matter. Is your calling function correct?

regards
David
>
>
>
> 11/26/02, David Vaughan wrote:
>
>> can you reveal some code?
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list