[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 MESSAGE...[IS...] TO

 Synopsis

         Forward message to variable

 Syntax

         MESSAGE <message name> [IS <target name>]
              TO <target variable>

 Arguments

         <message name> is the name of the message being declared.

         <target name> is the name of the message to be forwarded to
         the target variable. This argument should be omitted if its value
         is the same as <message name>.

         <target variable> is the name of the instance variable that
         the message is being forwarded to. The variable must already be
         defined in the current class or an ancestor class. Two special
         keywords can be used instead of specifying a target variable:
         CLASS <className> and SENDER. Their use is described
         below.

 Description

         This command causes the specified message to be forwarded to the
         object referred to by the specified target variable. This allows
         messages to be redirected automatically without requiring methods
         to be written. See Message Forwarding for more information.

         Instead of being forwarded to an instance variable in the current
         class, messages can be forwarded to an object's class using the
         CLASS <className> clause in place of the <target
         variable>. The name of the class being forwarded to should
         always be the name of the current class; other values will be
         ignored. This feature will be made more flexible in future
         versions.

         Examples of message forwarding are given below. Taken further,
         message forwarding can be used to implement a technique called
         delegation, which in its fullest sense involves communication
         in both directions between delegator and delegatee. One way to
         achieve this bi-directional communication, in a class which is
         designed to act as a target for delegation, is to use the keyword
         SENDER as the <target variable> in this command. This
         causes the specified message to be forwarded to the sending object
         (the delegator), allowing the receiver of a delegated message to
         communicate with the object which delegated the message. This is
         discussed further in the Delegation section.

 Example


           CLASS Graph
              VAR oWin // refers to Window object
              MESSAGE close TO oWin
              ...
           END CLASS

         This class specification would cause instances of the Graph class,
         upon receiving the close message, to reroute the message,
         including any parameters, to the object referred to by the
         instance variable oWin.

         Here is another example which makes use of the IS clause:

           CLASS Window
              VAR oCursor // refers to Cursor object
              MESSAGE hideCursor IS hide TO oCursor
              MESSAGE showCursor IS show TO oCursor
              MESSAGE updateCurs IS update TO oCursor
              ...
           END CLASS

         Based on these declarations, objects of class Window will respond
         to the messages hideCursor, showCursor and
         updateCursor by sending the message hide, show, or
         update respectively to the object referred to by the instance
         variable oCursor.

 See Also

         VAR...[IS...] TO, Message Forwarding, Delegation


See Also: VAR...[IS...] TO Message Forwarding Delegation
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson