[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
MESSAGE...METHOD
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 variable, 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 PROCEDURE or METHOD FUNCTION 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 reserved Nantucket name. Examples
of this are left, right, and at. These are functions
which the Clipper compiler handles specially, so having methods
with the same names is problematic. However, this does not prevent
the use of the same message name. To map a message to a method
with a different name, you would use a statement such as the
following:
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 message display to a method called boxDisplay. Now if
a UDF called Display() is called from within the boxDisplay method,
everything works as expected.
3. To map a message to a method which for some reason must be defined
in a module other than the one containing the class declaration.
This is not usually recommended practice, but it can be done. See
the section entitled 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 method and its associated message are flagged as a
constructor method and message respectively. See Constructor Messages
and Methods for more information.
See Also:
METHOD
External Methods
Constructor Messages and Methods
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson