implicitVars [Was: Re: Best Practices in Rev development]
-= JB =-
sundown at nwrain.net
Sat Jun 30 09:05:29 EDT 2007
On Jun 30, 2007, at 5:41 AM, David Bovill wrote:
> Firstly there was a typo in the example - but it also seems I was
> wrong. Its
> an old habit that perhaps was justified a long time ago?
>
> function countLines someLines
> repeat for each line someLine in someLines
> add 1 to lineCount
> end repeat
> return lineCount
> end countLines
>
> I do remember having errors in handlers where an a variable that
> was first
> declared/initiated inside a repeat loop (in this case "lineCount")
> would
> return the literal text "lineCount' and not empty if the repeat
> loop was
> never entered into (ie someLines) was empty - maybe it was just in
> a version
> of the debugger - no idea.
>
> Well one bad old habit fixed :)
Maybe you are thinking of a problem I have had which
was dealt with by declaring the variable just before I
do the repeat line. When I am going to add to a variable
I always make sure it has something to add to first.
put 0 into lineCount
> function countLines someLines
> repeat for each line someLine in someLines
> add 1 to lineCount
> end repeat
> return lineCount
> end countLines
-=>JB<=-
>
More information about the use-livecode
mailing list