Mac,
Just wanted to add a thought on your otherwise excellent example.
You may have heard of "short-circuit evaluation," the feature many programming languages use to stop evaluating compund IF statements when any condition fails.
To illustrate, assume you have IF A AND B. Languages using short-circuit evaluation stop parsing this line when A is FALSE. Languages that do not use short cicuit evaluation evaluate all conditions in the statement before determining whether or not to proceed, e.g. B gets evaluated even when A is already false.
Sadly, ObjectPAL does not use short cicuit evaluation. Because of this, it's best to avoid compund IF statements for performance reasons.
In this case, something like this may be more appropriate:
Code:
if not isEdit() then ;// "auto-edit"
self.action( dataBeginEdit )
endIf
if self.value = "" then ;// user cleared the value
return
endIf
;// if we get here, then it's a new value, so verify it.
if not tc.Locate( "Gang", temp ) then
showError()
else
addNewGang( temp )
endIf
(OK, I cheated a bit in replacing your msgQuestion with a custom routine, but you get the idea.)
Also, your "Gang name" error would also appear if the user accidentally exited edit mode before trying to depart. (This tends to happen more as a side-effect of sloppy coding than from anything the user does.) Reworking the IF as shown above provides a bit more accurate view of the picture.
Next, I don't really see a need for SWITCH in this context. Remember that Paradox evaluates all branches of SWITCH statements. Since you'll only get "Yes" or "No" from msgQuestion, the second evaluation is really unneccessary. A simple IF will suffice here, even when uChoice = "No"
(Y'know, now that I think about it, perhaps SWITCH is better for situations where you want behavior short-circuit evaluation.)
The performance differences may seem minor for things like canDepart, however, it can really add up in cases where you have large SWITCH statements (such as keyPhysical, action, menuAction, et al) or you call custom methods. Besides, every little bit helps.
Hope this does...
-- Lance