Re: local and do - what NOT to do

2016-02-18 Thread Mike Kerner
I skipped a few in the middle, here, but one case where I use do and value is in lieu of having pointers, something that is not very easily replaced by an array. Using value and do allow me to write generic routines for populating forms and updating database tables afterwards, using the field name

Re: local and do - what NOT to do

2016-02-18 Thread Richard Gaskin
Kay C Lan wrote: On Thu, Feb 18, 2016 at 7:52 PM, Mark Waddingham wrote: Okay so this kind of code pattern originates from HyperCard which did not have arrays. Upshot: There's no reason to use 'local' in do if you are initializing the variable at that point. Indeed, one could argue that it

Re: local and do - what NOT to do

2016-02-18 Thread [-hh]
Mark Wadd. wrote: > > [-hh] wrote: > > 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. > > Although you can do the above as: >local a -- only needed if in strict compilati

Re: local and do - what NOT to do

2016-02-18 Thread Kay C Lan
On Thu, Feb 18, 2016 at 7:52 PM, Mark Waddingham wrote: > >> Okay so this kind of code pattern originates from HyperCard which did not > have arrays. > > Upshot: There's no reason to use 'local' in do if you are initializing the > variable at that point. Indeed, one could argue that it is better

Re: local and do - what NOT to do

2016-02-18 Thread Mark Waddingham
On 2016-02-18 12:46, [-hh] wrote: 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 variabl

Re: local and do - what NOT to do

2016-02-18 Thread Mark Waddingham
On 2016-02-18 09:03, Kay C Lan 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 Okay so this kind of code pattern originates from HyperCard which did not ha

Re: local and do - what NOT to do

2016-02-18 Thread [-hh]
> 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

Re: local and do - what NOT to do

2016-02-18 Thread Peter TB Brett
On 18/02/2016 08:03, Kay C Lan 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

Re: local and do - what NOT to do

2016-02-18 Thread [-hh]
Kay C. L. wrote: > Moving right along, for those Slack Moders, if you run the same statements: > > repeat with x=1 to 20 > do "local tVar_" & x > do "put x*x into tVar_" & x > end repeat > put tVar_5 into msg --not hidden in > > For reasons I do NOT understand, you get a runtime error: > >

local and do - what NOT to do

2016-02-18 Thread Kay C Lan
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