In this section: |
When supplying an argument in a function, you must understand which types of arguments are acceptable, the formats and lengths for these arguments, and the number and order of these arguments.
The following are acceptable arguments for a function:
CURR_SAL * 1.03
and
FN || LN
Depending on the function, an argument can be in alphanumeric, numeric, or date format. If you supply an argument in the wrong format, you will cause an error or the function will not return correct data. The following are the types of argument formats:
All numeric arguments are converted to floating-point double-precision format when used with a function, but results are returned in the format specified for the output field.
Note: With CDN ON, numeric arguments must be delimited by a comma followed by a space.
If you supply an argument with a two-digit year, the function assigns a century based on the YRTHRESH and DEFCENT parameter settings.
An argument is passed to a function by reference, meaning that the memory location of the argument is passed. No indication of the length of the argument is given.
You must supply the argument length for alphanumeric strings. Some functions require a length for the input and output arguments (for example, SUBSTR), and others use one length for both arguments (for example, UPCASE).
Be careful to ensure that all lengths are correct. Providing an incorrect length can cause incorrect results:
Some operating system routines are very sensitive to incorrectly specified lengths and read them into incorrectly formatted memory areas.
The number of arguments required varies according to each function. Functions supplied by Information Builders may require up to six arguments. User-written subroutines may require a maximum of 200 arguments including the output argument. If a function requires more than 200 arguments, you must use two or more calls to pass the arguments to the function.
Arguments must be specified in the order shown in the syntax of each function. The required order varies according to the function.
How to: |
The USERFCHK setting controls the level of verification applied to DEFINE FUNCTION and Information Builders-supplied function arguments. It does not affect verification of the number of parameters; the correct number must always be supplied.
USERFCHK is not supported from Maintain Data.
Functions typically expect parameters to be a specific type or have a length that depends on the value of another parameter. It is possible in some situations to enforce these rules by truncating the length of a parameter and, therefore, avoid generating an error at run time.
The level of verification and possible conversion to a valid format performed depends on the specific function. The following two situations can usually be converted satisfactorily:
Parameter verification can be enabled only for DEFINE FUNCTIONs and functions supplied by Information Builders. If your site has a locally written function with the same name as an Information Builders-supplied function, the USERFNS setting determines which function is used.
SET USERFNS= {SYSTEM|LOCAL}
where:
Gives precedence to functions supplied by Information Builders. SYSTEM is the default value. This setting is required in order to enable parameter verification.
Gives precedence to locally written functions. Parameter verification is not performed with this setting in effect.
Note: When USERFNS is set to LOCAL, DT functions only display a six-digit date.
Issue the following command in FOCPARM, FOCPROF, on the command line, in a FOCEXEC, or in an ON TABLE command. Note that the USERFNS=SYSTEM setting must be in effect.
SET USERFCHK = setting
where:
Can be one of the following:
Because parameters are not verified for functions specified in a Master File, no errors are reported for those functions until the DEFINE field is used in a subsequent request when, if a problem occurs, the following message is generated:
(FOC003) THE FIELDNAME IS NOT RECOGNIZED
Note:
The following request uses SUBSTR to extract the substring that starts in position 6 and ends in position 14 of the TITLE field. The fifth argument specifies a substring length (500) that is too long (it should be no longer than 9).
SET USERFCHK = ON TABLE FILE MOVIES PRINT TITLE COMPUTE NEWTITLE/A9 = SUBSTR(39, TITLE, 6 ,14, 500, NEWTITLE); WHERE CATEGORY EQ 'CHILDREN' END
When the request is executed with USERFCHK=ON or OFF, the incorrect length is corrected and the request continues processing:
TITLE NEWTITLE ----- -------- SMURFS, THE S, THE SHAGGY DOG, THE Y DOG, TH SCOOBY-DOO-A DOG IN THE RUFF Y-DOO-A D ALICE IN WONDERLAND IN WONDE SESAME STREET-BEDTIME STORIES AND SONGS E STREET- ROMPER ROOM-ASK MISS MOLLY R ROOM-AS SLEEPING BEAUTY ING BEAUT BAMBI
The following request has an incorrect data type in the last argument to SUBSTR. This parameter should specify an alphanumeric field or format for the extracted substring:
SET USERFCHK = ON TABLE FILE MOVIES PRINT TITLE COMPUTE NEWTITLE/F9 = SUBSTR(39, TITLE, 6 ,14, 500, 'F9'); WHERE CATEGORY EQ 'CHILDREN' END
ERROR AT OR NEAR LINE 5 IN PROCEDURE USERFC3 FOCEXEC (FOC279) NUMERIC ARGUMENTS IN PLACE WHERE ALPHA ARE CALLED FOR (FOC009) INCOMPLETE REQUEST STATEMENT UNKNOWN FOCUS COMMAND WHERE BYPASSING TO END OF COMMAND
DIRECTOR TITLE NEWTITLE -------- ----- -------- SMURFS, THE ********* BARTON C. SHAGGY DOG, THE ********* SCOOBY-DOO-A DOG IN THE RUFF ********* GEROMINI ALICE IN WONDERLAND 1 SESAME STREET-BEDTIME STORIES AND SONGS -265774 ROMPER ROOM-ASK MISS MOLLY ********* DISNEY W. SLEEPING BEAUTY ********* DISNEY W. BAMBI 0