Bug or just something you can't do ?

Richard Gaskin ambassador at fourthworld.com
Sun Sep 30 19:15:21 EDT 2012


Alex Tweedly wrote:
> This very simple script doesn't work. Question is whether it should or not ?
>> command increment @p
>>    add 1 to p
>> end increment
>>
>> on mouseUp
>>    local t, tA
>>    put 2 into t
>>    increment t
>>    put t &CR after msg
>>
>>    put 5 into tA[1]
>>    increment tA[1]
>>    put tA[1] &CR after msg
>>
>> end mouseUp
> Intutively, to me, it should work. The element of the array can be
> treated just like a simple variable - use its value, assign to it, etc.
> -  but it cannot be used as the actual parameter to a pass-by-reference
> parameter.
>
> I can't find anywhere in the documentation that says that - but I can't
> actually find anywhere that it would say that - the docs I've found are
> pretty quiet on the subject of what an array is, or what an element is.
>
> Is this a deficiency you would expect ?
> Or should I submit as a bug/request ?

I would have expected it, but I can see value in allowing what you 
suggest.  I'm just not sure how to go about it.

Args are evaluated before being passed in, so:

    increment tA[1]

...becomes:

    increment (the value of element "1" in the array tA)

One option for passing the array would be to pass the whole thing with a 
specifier for the element to be affected as a separate argument:

   increment tA, 1

But you've probably already considered that.

So we have a question:  if enough folks find this sort of suggested 
syntax useful, by what syntactic means could we tell the interpreter not 
to evaluate the argument?

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  Follow me on Twitter:  http://twitter.com/FourthWorldSys




More information about the use-livecode mailing list