dQuiz #2 Solution
by Peter Rorlick

Like most people, you probably guessed “ENTRYFIELD”.  But in fact the message box shows “MyForm”.

Is this a bug in dBASE?  No. According to Ken Chan, this is WAD (Working As Designed) - and documented (see below). He says that “this behavior may be a by-product of dBASE's pass-by-reference nature”.

For the msgbox() to show “ENTRYFIELD” (the behavior we're more likely to desire), we must enclose the this in parentheses:

 form.xyz( (this) )

The extra parentheses force the evaluation of the object reference.  That reference is then passed to the method.

Here's an extract from the “PARAMETERS” topic in the On-Line Help:

Passing this and form

When passing the special object references this and form as parameters to the method of another object, they must be enclosed in parentheses to be passed by value. If not, the value of the this and form parameters take on the corresponding values for the target object, and no longer refer to the calling objects.

Back to the dQuiz