Several macros available within an external function enforce calling conventions and provide useful error messages when these conventions are violated. The following information describes these macros.
DEFARG(fldname, datatype, direction)
The DEFARG macro defines the next argument to the function. One should appear for each argument used by the function.
fldname
is a symbolic name used to refer to the argument in documentation and error messages. It follows the normal naming conventions, a maximum of 24 characters consisting of alphanumeric or the underscore.datatype
is one of the four defined datatypes: num, char, date, or time. A special datatype, phrase, is allowed only in the DEFARG macro. The num datatype is stored as a long integer, while the char, date, and time datatypes are stored as strings. The phrase datatype is defined only for passing arguments to an External Function and is converted to a phrase number.direction
is the direction in which data is passed: in, out, or both. Specify in if the data will be used, but not modified by the external function. In this case, the application may pass numeric or string constants to the function. Otherwise, the system generates an error message if the application attempts to use a constant for an argument. Specify out if the field is used to return data to the calling application. Specify both if the field is used and possibly modified by the function. In these cases, the external function must know how big the field is and ensure it does not overrun the field. This can be done by defining a numeric argument that specifies maximum size, or by documenting any assumed restrictions on the field that the caller is expected to meet.Directions out and both are allowed for num, char, date, and time, but are not allowed for phrase.
DEFARG_COUNT(n)
This macro specifies the number of arguments used by the function. The number can be from 0 through 5. This macro is optional.