[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
MESSAGE...METHOD
Synopsis
Declare message and corresponding method
Syntax
MESSAGE <message name> METHOD <method name>
[CONSTRUCTOR | CTOR]
Arguments
<message name> is the name of the message being declared. Like
a Clipper function or variable name, up to 10 characters are
significant. Extra characters will be ignored.
<method name> is the name of the method to invoke when the
specified message is sent. A method of this name should be defined
later in the same module using the METHOD definition command,
unless an external method is being declared.
Description
This command allows a method to be declared which is invoked by a
message with a name different from that of the method. This may be
necessary for one of several reasons:
1. The message name conflicts with a Clipper reserved name. Examples
of this are left, delete, and at (see the Clipper
documentation section on reserved words). These are names which
the Clipper compiler handles specially, so having methods with the
same names is problematic. However, this does not prevent the use
of these names as messages. To map a message to a method with a
different name, a statement such as the following can be used:
MESSAGE left METHOD boxLeft
In this example, the message left is mapped to the method
called boxLeft.
2. When an ordinary function is called which has the same name as the
method from which it is being called. For example, attempting to
call a function called Display() from a method called
display will result in an endless recursive loop. To resolve
this, give the method a different name, for example:
MESSAGE display METHOD boxDisplay
This maps the display message to a method called boxDisplay.
Now if a function called Display() is called from within the
boxDisplay method, everything works as expected.
3. To map a message to a method which is defined in a module other
than the one containing the class specification. This is not
recommended practice. See External Methods.
4. To map two or more messages in a class to the same method. This
might be required to support an obsolete message which is still in
use. For example:
MESSAGE getValue METHOD get
METHOD get
In this case, the messages getValue and get both map to
the same method, named get. Note that the second statement
above uses the default behaviour of the METHOD command to name
a message and method the same name - it would be unnecessary
(although it would work) to use MESSAGE get METHOD get.
Note
If the optional CONSTRUCTOR clause is included (or its
abbreviation CTOR), then the message is flagged as a
constructor message. See Constructor Messages and Methods
for more information.
See Also
METHOD (declaration), METHOD (definition), External
Methods, Constructor Messages and Methods
See Also:
METHOD (declaration)
METHOD (definition)
External Methods
Constructor Messages
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson