local and do <commands> - what NOT to do
-hh
hh at livecode.org
Thu Feb 18 06:46:31 EST 2016
> Peter B. wrote:
> > The Dictionary entry for 'local' has this Example:
> >
> > -- To make a numbered list of variables:
> > repeat with x=1 to 20
> > do "local tVar_" & x & "; put empty into tVar_" & x
> > end repeat
> >
> > Which 'apparently' runs fine if you copy and paste it into the msg box. For
> > the purposes of this discussion and so we can see what's going on I'm going
> > to remix that to:
>
> Are there any problems that can be solved by generating variable names, that
> couldn't be solved equally well (and without using "do") using an array? Peter
Just now I can't think of an example for *generating* variable names only.
But there are very simple and important ones for *using* variable names:
local a1=1, a2=false
-- local a[1]=1, a[2]=false #<-- currently not allowed
For such default-constructs variable names and using "do" are really helpful.
More information about the use-livecode
mailing list