Hi,

When I have a handler which has an optional parameter (see below) I usually just test for VOID. If the parameter is VOID then I use a default value.

However with a handler I am writing at the moment it is possible that I will forget the rules (at some point in the future) and pass in a FALSE value or a 0 (zero). These will act as if they are VOID if I test them. This could mess things up, resulting in the opposite result to the one intended and also get around my error checking as it now stands.

Any thoughts?

Maybe I am better off having two handlers. One for "combined" and another for "notCombined". It might be less dangerous and less ambiguous.


This is a "public" handler in a parent script which accepts input from other code objects.
******************


-- accepts "combined" message
-- inputs: flag - (optional) should be symbol #true or #false
--
-- affects: pCombined - a property variable which lets the object know -- if it is combined with another movement object
-- or not
--
-- if no value is passed then pCombined = TRUE


on combined me, flag

if flag <> VOID then

    if flag = #true then
      pCombined = TRUE
    else if flag = #false then
      pCombined = FALSE
    else if the runMode contains "Author" then
      alert "The parameter passed to the 'combined' method
             in 'linearMove parent' needs to be the symbols #true or
             #false. Other values including booleans will not work
             properly."
    end if

  else -- if flag = VOID (which is supposed to take care of situation
       -- when no value is passed, which will probably be most of the
       -- time - though a FALSE or 0 would slip through).

pCombined = TRUE

end if

end

******************

Thanks in advance,

John

[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]

Reply via email to