implicitVars [Was: Re: Best Practices in Rev development]
David Bovill
david at openpartnership.net
Sat Jul 14 14:48:35 EDT 2007
On 29/06/07, Jim Ault <JimAultWins at yahoo.com> wrote:
>
>
> I am a bit confused.. why would you pass a param then set it to empty?
> or establish the param and declare it as a local, as you do later?
>
> What is the benefit?
Finally - found a reason :)
Call by references ! I quite often in repeat loops use a call-by-reference
command to increment (or modify) some value. If you do not implicity declare
the variable you get a nasty error when the repeat loop is not executed
because something is empty.... an example may help.
There may be other examples, but take this simplified script:
on mouseUp
repeat 0
addAnA string
end repeat
put string
end mouseUp
on addAnA @string
put "a" after string
end addAnA
This does not result in an empty string, but "string"
More information about the use-livecode
mailing list