Variable convention questions

Fred_D_Yocum at mail.mcc.org Fred_D_Yocum at mail.mcc.org
Fri Sep 27 07:42:01 EDT 2002


I have just hand-rolled my first real handler/function. It, puts the list of
files that end in "txt" which are in the same folder/directory as the stack into
a variable called theList.
-----------------
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?

There is a variable created in this line "repeat for each line thisLine in
theFileList" which  I filched the method from the "repeat" section of the
Transcript dictionary. Why should it work?  I would have thought I would have
had to do something like below (except "this" is reserved for cards and stacks)
:

"repeat for each line of theFileList
  set theLine to this line... "

It seems logically inconsistent to create variable simply by placing it after
"repeat for each line". Why does it work?

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

TIA, Fred D






More information about the use-livecode mailing list