How to: Reference: |
The temporary fields you create with the Define and Compute expressions are tied to a specific Master File, and in the case of values calculated with the COMPUTE command Compute expression, to a specific request. However, you can create temporary fields that are independent of either a Master File or a request using the DEFINE FUNCTION command.
A DEFINE function is a named group of calculations that use any number of input values and produce a return value. When calling a DEFINE function, you must first define the function.
A DEFINE function can be called in most of the same situations that are valid for Information Builders-supplied functions. Data types are defined with each argument. When substituting values for these arguments, the format must match the defined format. Alphanumeric arguments shorter than the specified format are padded with blanks, while longer alphanumeric arguments are truncated.
All calculations within the function are done in double precision. Format conversions occur only across equal signs (=) in the assignments that define temporary fields.
DEFINE FUNCTION name (argument1/format1,..., argumentn/formatn) [tempvariablea/formata [TITLE 'line1[,line2 ...'] [DESCRiption 'description'] = expressiona;] . . . [tempvariablex/formatx = expressionx;] name/format = [result_expression]; END
where:
Is the name of the function, up to 64 characters. This must be the last field calculated in the function, and is used to return the value of the function to the calling procedure.
Are the argument names. They can be any names that comply with FOCUS field naming rules.
Are the formats of the function arguments.
If the format of an argument is alphanumeric, the argument value must also be alphanumeric. Shorter arguments are padded on the right with blanks, and longer arguments are truncated.
If the format of an argument is numeric, the argument value must also be numeric. To prevent unexpected results, you must be consistent in your use of data types.
Are temporary fields. Temporary fields hold intermediate values used in the function. You can define as many temporary fields as you need.
Are the formats of the temporary fields.
Are the lines of default column title to be displayed for the virtual field unless overridden by an AS phrase.
Is the description to be associated with the virtual field.
Are the expressions that calculate the temporary field values. The expressions can use parameters, constants, and other temporary fields defined in the same function.
Is the format of the value the function returns.
Is the expression that calculates the value returned by the function. The expression can use parameters, constants, and temporary fields defined in the same function.
(FOC03665) Error loading external function '%1'
Issue the following command from the Command Console:
? FUNCTION
Issuing the command
? FUNCTION
displays information similar to the following:
FUNCTIONS | CURRENTLY | ACTIVE | |
NAME | FORMAT | PARAMETER | FORMAT |
---------- | --------- | --------- | ------- |
SUBTRACT | D8.2 | VAL1 | D8 |
VAL2 | D8 |
If you issue the ? FUNCTION command when no functions are defined, the following appears:
NO FUNCTIONS CURRENTLY IN EFFECT
DEFINE FUNCTION {name|*} CLEAR
where:
WebFOCUS |