On 17/6/04 6:11 am, "Christoffer Enedahl" <christoffer@...> wrote:
> I had some time to tweak the approved openLingo scripts tonight between the
> children screams.
Hi everyone,
I notice that the approved scripts contain structures like:
on getCount me
_errorSymbol = void --Reset any previous error
if ListP( me._instancePropList ) then return me._instancePropList.count
else return 0
end
I would suggest restructuring the handler above as:
on getCount me
_errorSymbol = void --Reset any previous error
-- Place "if ... then" and action on separate lines
if ListP(_instancePropList) then -- no "me."
tResult = _instancePropList.count
else
tResult = 0
end if
return tResult -- calculate result and return it on different lines
end getCount
I'm new to this list, so perhaps there are reasons for working in the
approved way that I am not aware of. My reasons for the changes are
connected with debugging:
* If the "if ... then" statement is on the same line as the action it
generates, step by step debugging will not show whether the line is
executed or not
* If the result is calculated on the same line as it is returned,
you may not be able to see what value *is* returned, either in the
current handler or in the calling handler.
* The "me." prefix is unnecessary for properties declared in the
current script. It is only required if the property is declared
in an ancestor. I omit the "me." where possible, so that it is
clear when a property is "personal" or "inherited".
(The "t" prefix for temporary variables follows the practice used in the
more recent Director behaviors, which also use a "p" prefix for properties).
Does this make sense, or am I being pedantic?
James