implicitVars [Was: Re: Best Practices in Rev development]

Joe Lewis Wilkins pepetoo at cox.net
Sat Jun 30 12:03:53 EDT 2007


Hi David,

Even in HC, I would have initiated the var lineCount to zero (put 0  
into lineCount) before attempting to add something to it, in which  
case if someLines was empty it would already have a valid value to be  
returned.

Joe Wilkins

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 :)
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list