Statement METHOD (Declaration) Foundation
Declares instance methods of a class (methods of the instance objects)
METHOD <MethodName,...>
or
METHOD <MessageName> [IS <MethodName>] [IN <SuperClass>]
The declaration METHOD within the class declaration (between the CLASS...ENDCLASS statements) declares a method as an instance method of the class. Instance methods can be executed from all instances (objects) of a class, but not from the class object.
The method must be declared in the class declaration (between the CLASS...ENDCLASS statements) by the declaration METHOD <MethodName>. The code for the method must be programmed separately after the statement ENDCLASS. If the method is already implemented in a superclass or is associated with a specific superclass by the option IN, the method does not need to be programmed within this class. An object of this new class executes the source code from the superclass for the corresponding method. When the method <MethodName> is implemented both in a superclass and in this declared class, an object of the class executes this class method and not the method of the same name in a superclass.
Within the source code of a method, the object executing the method can always be referenced through the variable self. In sending a message to the object from within the code of a method (to access a member variable or execute another method) the operator :: can be used as an abbreviation for self:.
The name of the instance method is always <MethodName> where it prefaces the method's code. When the method is declared as <MessageName> IS <MethodName>, <MessageName> determines the message which must be sent to an object so that the method <MethodName> is executed.
<MessageName> can be used to define an alternative name for a method. It can also be used when the instance method is not implemented in the declared class but in one of its superclasses. When two or more superclasses exist which have the same names for methods, it is recommended that unique alternative names be declared to call the methods in each superclass. In this case the declaration is used in the form METHOD..IS..IN.
The visibility of a method is determined by the visibility attribute set with one of the statements EXPORTED:, PROTECTED: or HIDDEN: (see the section on each visibility attribute for more information).
Reserved names: The identifier new is reserved and cannot be used for a method name. Also the identifier init is reserved for the initialization of an instance (object).
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.