Object Methods

The methods associated with an object define the operations or procedures that manipulate object data. For example, if you define an object called Telephone, methods used by the Telephone object may include the Ring method and the Call Forward method. In PSL, methods for objects defined in the ResultSet class include getCol, getRow, isEmpty, and next.

A method contains executable code similar to functions or procedures. You can pass parameters to the method from the calling program; the method can also return a result to the calling program. A method declaration defines the type of value returned by the method. If the method does not return a value, declare the method return type as "void."

The return has to match the object type.

Inheritance of Methods

A subclass inherits the methods of its superclass. Therefore, because the Object class is a superclass for all other classes, all classes inherit the methods defined for the Object class. During processing, if procedure code references a method that is not defined for the specified object, the system looks for the method in any superclasses defined for the class. For example, if the procedure code references the copy() method, but the class of the associated object does not define a copy() method, the system processes the copy() method that is defined for the superclass (or the Object class if no other superclass is associated with the object). However, if a method of the same name, number of parameters, and types of parameters exists for both the subclass and the superclass, the subclass uses its own method.

Invoking a Class Method

You can invoke a class method in two ways:

set rs = Db.getRecord("CIF","ACN")

do dep.save()

image\msgs.gif

PSL does not support "overloading methods." That is, you cannot create methods with the same name but different numbers or types of parameters.

Implementing Methods

For information on implementing methods, refer to the Implementing Methods section.