Probably worth mentioning the "@" syntax for a command handler parameter.
If you have a handler: command foo parm1,@parm2 --do stuff that puts a new value into parm2 end foo .. then you call it: foo tlocal1,tlocal2 ... tlocal2 will contain the new value put into it after foo has processed it. I find this useful for things like generic text manipulation commands which, eg, remove certain characters or replace them with another character, where you don't care about the original value of the string you're changing. Pete Molly's Revenge <http://www.mollysrevenge.com> On Thu, Jun 16, 2011 at 4:34 PM, Ken Ray <[email protected]> wrote: > > > 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: [email protected] > Web Site: http://www.sonsothunder.com/ > > > > _______________________________________________ > use-livecode mailing list > [email protected] > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > > _______________________________________________ use-livecode mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
