Calling a Function

How to:

You can call a function from a COMPUTE, DEFINE, or VALIDATE command. You can also call functions from a Dialogue Manager command, a Financial Modeling Language (FML) command, or a Maintain command. A function is called with the function name, arguments, and, for external functions, an output field.

For more information on external functions, see Types of Functions.

Some Maintain-specific functions require that the MNTUWS function library be retrieved when calling the function. For functions that require this, it is specified in the detailed information for that function. For more information on retrieving the MNTUWS library, see How to Access the Maintain MNTUWS Function Library.


Top of page

x
Syntax: How to Call a Function
function(arg1, arg2, ... [outfield])

where:

function

Is the name of the function.

arg1, arg2, ...

Are the arguments.

outfield

Is the field that contains the result, or the format of the output value enclosed in single quotation marks. This argument is required only for external functions.

In Dialogue Manager, you must specify the format. In Maintain, you must specify the name of the field.


Top of page

x
Syntax: How to Store Output in a Field
COMPUTE field/fmt = function(input1, input2,... [outfield]);

or

DEFINE FILE file
field/fmt = function(input1, input2,... [outfield]);

or

-SET &var = function(input1, input2,... [outfield]);

where:

DEFINE

Creates a virtual field that may be used in a request as though it is a real data source field.

COMPUTE

Calculates one or more temporary fields in a request. The field is calculated after all records have been selected, sorted, and summed.

field

Is the field that contains the result.

file

Is the file in which the virtual field is created.

var

Is the variable that contains the result.

fmt

Is the format of the field that contains the result.

function

Is the name of the function, up to eight characters long.

input1, input2,...

Are the input arguments, which are data values or fields used in function processing. For more information about arguments, see Supplying an Argument in a Function.

outfield

Is the field that contains the result, or the format of the output value enclosed in single quotation marks. This argument is required only for external functions.

In Dialogue Manager, you must specify the format. In Maintain, you must specify the name of the field.


Top of page

x
Syntax: How to Access the Maintain MNTUWS Function Library

Place the following statement directly after the MAINTAIN command at the top of your procedure:

MODULE IMPORT (MNTUWS);

WebFOCUS