Bug or just something you can't do ?
Alex Tweedly
alex at tweedly.net
Mon Oct 1 18:36:42 EDT 2012
On 01/10/2012 17:40, Bob Sneidar wrote:
> It's my understanding that presently you cannot pass an array element by reference. You can only pass the entire array.
>
Yeah - that's the whole problem I am complaining about :-)
> Instead try passing the entire array, then checking inside your command to see if it is an array and then act accordingly.
I can't see how to do that (without some *really* ugly code within the
handler). The problem is that (in the handler) the parameter is an array
passed in by reference so that it can be modified; sometimes I want to
call it with an entire array, others with a sub-array (i.e. an array
element which is itself an array). So the handler can't simply check
whether what was passed was an array. It could require an extra
parameter for the array index, and if that was empty use the array
parameter as itself, and if non-empty it could index the array - but
that means that every usage of the parameter within the handler becomes
subject to an if-test. Oh, btw, the real handler has more than one such
parameter :-(
(example below in case that's not clear).
In any case, Pete has confirmed that it is already in QCC as 10070 and
7167 - both marked as duplicate of 6820 It has been open, but
"unconfirmed" (though commented on by Mark W), for over 4 years - which
pretty much tells me not to hold my breath ;-)
I'll just carry on with the ugly work-around described earlier of
copying the element into a top-level array, passing that, and copying
back afterwards ..... sigh.
Thanks everyone for your help and comments.
-- Alex.
(example - vaguely close to though simpler than the real example)
in my library stack (used in 90% of my current projects)
function readData pURL, @pData, @pInverse
put URL (pURL) into temp
repeat for each line L in temp
add 1 to tCount
put item 2 to -1 of L into pData[item 1 of L]
repeat for each item K in (item 2 to -1 of L)
put L &CR after pInverse[K]
end repeat
end repeat
return tCount
end readData
and in some stacks I just do
local pData, pInverse
put empty into pData
put empty into pIndex
put readData( someURL, pData, pInverse) into tC
....
while in others I'd do
repeat for each line thisURL in tListOfURLs
put readData( thisURL, pData[thisURL], pInverse) into
pData[thisURL]["count"]
end repeat
...
i.e. can be either a whole array or a sub-array.
More information about the use-livecode
mailing list