Hi Tom,

Here are some simple ways I figure out whether to use a command or a function in a given situation.

A function name can naturally take on the role of a noun in a sentence. Or in RunRev terms, it can naturally fill the role of a containerName. A good function name can really improve the readability of the code in those places where it is used.

  put selectedTunes() into fld "tuneList"
  put cardObjectIDs("firstCard") into tObjectList
  if errorCount() > 3 then...

In each of the above cases, a function name takes the place of a subprocess that is probably secondary to the purpose of the calling handler. That secondary code is moved to a place of its own, where it can be appreciated for its value instead of cursed as a distraction, as it might be if it were coded inline. Without functions, code would be a lot harder to read.


A command name can be a short imperative sentence without the spaces:

  refreshMembersList
  closeCurrentScreen
  startMotor
  moveRobotArm "left",5 -- this one has 2 parameters

If at a given spot in your code, you can describe what needs to be done in a short sentence like the ones above, a command will probably serve well in that spot.


This isn't exactly what you asked for, but maybe it helps.

Phil Davis



Thomas McGrath III wrote:
Hello listeroos,

Can someone give the long answer on when is it best to use a function versus a command? I have a lot to write of both commands and functions and have been overly confusing myself. Please give at least two examples each with parameters and how to call/use them.

Much appreciated,

Tom


Thomas J McGrath III
[EMAIL PROTECTED]

Lazy River Software™ - http://www.lazyriversoftware.com

Lazy River Metal Art™ - http://www.lazyriversoftware.com/metal.html

Meeting Wear™ - http://www.cafepress.com/meetingwear

Semantic Compaction Systems - http://www.minspeak.com

SCIconics, LLC - http://www.sciconics.com/sciindex.html

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to