ProvideX V8.20 > Language Reference > 2. Directives
137
if ... ... ... etc
FUNCTION MySecondMethod()
a=b, d=f
if ... ... ... etc
FUNCTION END
END DEF
Every method should return a value. The value can take the form of a string or
numeric value depending on the name associated with the function (string functions
must end with $). If no RETURN value is specified, then the system will return a
value of zero for numeric functions and "" (null) for string functions.
Note: As a general rule of thumb, methods should return a non-zero value when
successfully executed. This allows for logic such as:
IF NOT(Cst'Find("ABCD")) THEN GOTO Bad_cust.
When arguments are used in the definition, then the type/number should normally
match variables in the application code. Multiple definitions of the same method
name can be specified, as long as each method has a different parameter list. In order
to determine which method to actually use, ProvideX attempts to match up the
parameter lists specified with the variables provided in the application.
If an asterisk * is used in the definition in place of the argument list (e.g., FUNCTION
readbykey(*)), the method will be invoked regardless of the type/number of
variables to be matched in the corresponding logic.
FUNCTION PERFORM indicates that the function logic is to be loaded and executed
(as in a PERFORM directive). All variables will be shared with the calling program.
Note: The PERFORM format violates the general rules of OOP encapsulation.
FUNCTION LOCAL indicates that the function is only to be called internally from
within the object. It cannot be called externally.
Examples
FUNCTION Find(X$) LookupByName
FUNCTION Find(X) LookupByNumber
... ... ...
LookupByName:
ENTER Cst_id$
... ... ... ! Logic to find the client by name
RETURN ...
LookupByNumber:
ENTER Cst_id
... ... ... ! Logic to find the client by number
RETURN ...
See Also
Object Oriented Programming, p.21
DEF CLASS Define Object Class, p.64
ON EVENT Event Processing, p.227