Programming Guide : 4. Working with Classes : How You Can Create a User Class : How You Can Write Methods
 
Share this page                  
How You Can Write Methods
You access the script for the methods of a user class from the Class Editor. For procedures to edit a method script, see the Workbench User Guide.
The methods created in the script must correspond to methods defined for the user class. For the syntax for writing a method script, see the Language Reference Guide.
The 4GL code for a method can make use of two predefined system variables:
CurObject
References the current instance of the user class. It provides access to every attribute of the current instance of a user class to every method for that class. When defining a method's functions, you access attributes of the current user class by using the CurObject system variable.
For example, the first function of the Employee class's Hire method is to check for the employee's hire date. If no date has been assigned, the method supplies the Ingres special constant (today) for the current date. The Hire method refers to the HireDate attribute of the object on which the method is invoked by using the CurObject system variable.
The following code performs this function:
if CurObject.HireDate = '' then
   CurObject.HireDate = 'today';
endif;
When you invoke the Hire method on an object called tempemp, CurObject refers to tempemp.
CurMethod
This variable refers to the running instance of the current method. It is analogous to CurProcedure for a procedure. For example, the TempEmployee script that redefines the Hire method includes the following statement to display a predefined popup:
if CurObject.TerminationDate = '' then
   CurMethod.InfoPopup(messagetext =
       'Temporary employees must have a
       termination' + ' date specified.',
       messagetype = MT_ERROR);
For more information about defining methods in user class scripts, see the Language Reference Guide.