Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?

FUNCTION

Description

Identifies a user-defined function, which can be invoked by other jBASE BASIC programs. Arguments to the function can optionally be declared. It takes the general from: 

FUNCTION name {({MAT} variable, {MAT} variable...) }


Where: 

Name is the name by which the function is invoked.

Variable is an expression used to pass values between the calling program and the function.

The FUNCTION statement is used to identify user-written source code functions. Each function must be coded in separate records and the record Id must match that of the Function Name, which in turn should match the reference in the calling program.

The optional comma separated variable list can be a number of expressions that pass values between the calling programs and the function. To pass an array the variable name must be preceded by the MAT keyword. When a user-written function is called, the calling program must specify the same number of variables that are specified in the FUNCTION statement.

An extra 'hidden' variable is used to return a value from the user-written function. The value to be returned can be specified within the Function by the RETURN(value) statement. If using the RETURN statement without a value then by default it returns an empty string.

The calling program must specify a DEFFUN or DEFB statement to describe the function to be called and the function source must be cataloged and locatable similar to subroutines.

An example of use would be: 

FUNCTION MyFunction(A, B)
Result = A * B
RETURN (Result)


Go back to jBASE BASIC.

Was this article helpful?