Variable convention questions

Richard Gaskin ambassador at fourthworld.com
Fri Sep 27 08:52:01 EDT 2002


Fred_D_Yocum at mail.mcc.org wrote:

> -----------------
> on buildPickList theList
> set the itemDelimiter to "/"
> set the defaultFolder to item 1 to -2 of the effective filename of this stack
> put the files into theFileList
> repeat for each line thisLine in theFileList
> if char -3 to -1 of thisLine is "txt" then put thisLine & return after theList
> end repeat
> end buildPickList
> -----------------
> 
> Since I am new to programming and Rev I've got questions regarding variables.
> I haven't declared the variables at the beginning of the function.
> Is this good practice?

You can optionally declare variables locally if you prefer; you can enforce
this by setting the explicitVariables property to true.

Good practice?  It does require more discipline and a little extra typing,
but can help debugging.  It has no effect one way or another on performance.
I think this one may be considered a matter of taste.

> Aside the above can the function be improved/made more efficent?

You can replace:

  repeat for each line thisLine in theFileList
   if char -3 to -1 of thisLine is "txt" then put thisLine & \
     return after theList
  end repeat

...with:

  filter theList with "*.txt"

-- 
 Richard Gaskin 
 Fourth World Media Corporation
 Custom Software and Web Development for All Major Platforms
 Developer of WebMerge 2.0: Publish any database on any site
 ___________________________________________________________
 Ambassador at FourthWorld.com       http://www.FourthWorld.com
 Tel: 323-225-3717                       AIM: FourthWorldInc




More information about the use-livecode mailing list