Functions (was: Re: horizontal and vertical scrolling)
Ken Ray
kray at sonsothunder.com
Thu Jun 16 19:34:08 EDT 2011
> If anyone wants to provide some rules of thumb for when you use a
> function and when you don't, that might be interesting.
In general I use functions when the main point is to process something and
return a value, and I use command handlers when I want to "do" something
that may or may not return a value.
For example, extracting a column of data from a container is a function,
while printing something is a command handler. Even though a command handler
can return a value, usually this is the exception, not the rule - and most
of the time what's returned is an error (if anything). It's a mimic of the
language... imagine the "create folder" command being wrapped up in a
handler:
on CreateFolder pFolderPath
create folder pFolderPath
put the result into tResult
return tResult
end CreateFolder
Now compare the raw command with the command handler:
create folder "MyFolder"
if the result is not empty then... --- there's an error
CreateFolder "MyFolder"
if the result is not empty then... --- there's an error
Anyway, that's my 2 cents...
Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode
mailing list