Programming Guide : Working with Classes : How You Can Reference Objects : How You Can Invoke Methods
 
Share this page          
How You Can Invoke Methods
To invoke a method for an object, use the same dot notation that you use for referencing attributes. If the method has parameters, you must specify the parameters by name, just as you do with the parameters for a frame or procedure. If the method has no parameters or you do not want to specify parameters, you must include a pair of empty parentheses. The basic syntax is:
reference_variable.method({parameter_list})
reference_variable
Specifies the name of the reference variable that points to the object
method
Specifies any one of the methods defined for the object's system class
parameter_list
Specifies an optional list of parameters using the following syntax:
parameter_name = expression {, parameter_name = expression}
parameter_name
Specifies any of the parameters defined for the method
expression
Specifies any 4GL expression that is the appropriate type for the particular parameter
You can specify the parameters in any order.
To invoke a method for a field or menu item object, use the field function to return the reference variable:
field(display_variable).method([parameter_list])
The following example illustrates this:
field(acctno_form.acctno).MarkAllText();
A method may return a value. You must specify a variable name to receive the return value. The syntax is:
variable = reference_variable.method([parameter_list])
variable
Specifies any variable in the current scope and must have an appropriate data type
The following example specifies the video variable to hold the return value for the Create method (that is, to be the object created):
video = VIDEO_ROW.Create();
When the method returns a value, you can use it as an expression or as part of an expression in an OpenROAD statement. The following example uses the value set by the user's response in an expression:
if CurFrame.ConfirmPopup(messagetext =
    'some message') =  PU_OK then ...;
For a complete list of the methods that are defined for each system class and for the data type of each method's return value, see the Language Reference Guide online help.