Support DLL functions are invoked using the following syntax:

$set_var varname "$fn:functionname(parmlist)"

The items in this example have the following significance:

varname the name of a variable to be set, normally without an @ prefix.
$fn: a required identifier prefix.
functionname the name of one of the provided functions listed below. Note that these are not functions that have normal entry points within the DLL that can be called from other programs. Function names are not case-sensitive.
parmlist a list of parameters that must be supplied to the function, in parentheses.Parameters must be comma-separated. Each parameter may optionally be enclosed in single quotes (') and must be enclosed in single quotes if it contains commas or leading or trailing spaces. Otherwise leading and trailing spaces are trimmed from parameters so you can use whatever spacing you prefer for appearance. You must enclose the entire function syntax in double quotes (") if any portion of it contains a space.

Functions may not be 'nested' in the parameter list. You must assign to an intermediate variable and use that variable in the parameter list of the subsequent function. Normal CopiaFacts variables may be used anywhere in the function name or parameter list with the usual @ syntax.

If the function is successful, the variable varname will contain the result of the function and the system variable FUNCTION_RETURN will contain a value of zero. If one of the function parameters was missing or invalid then FUNCTION_RETURN will contain a value of 1 and an empty value will be assigned to the specfied variable varname. Serious errors during function evaluation will result in a negative value being placed in FUNCTION_RETURN as described below.

Dates and times passed into the functions as arguments may either use USA sequence and delimiters (mm/dd/yyyy, hh:mm:ss) or LOCAL sequence and delimiters, determined by the Windows locale settings on your machine. The default is LOCAL. You can change the setting during a call by assigning a value USA or LOCAL to system variable SF_DATETIME_PARM. This only changes the expected format of input parameters to the functions and has no effect on output formats.

We strongly recommend using four-digit years when supplying a parameter passed to any of the date functions. If a date supplied to a function contains only two digits of year, then a century value is added to the supplied date. The century used for this purpose is based on a 'pivot year' which is the current year less 50 years. Thus in 2002, a passed year of 51 becomes 2051 and a passed year of 52 becomes 1952.

Two special system variables control 'output' date formats for function results. Assignments to SF_DATE_FORMAT and SF_TIME_FORMAT variables may be made at any time to change the format returned by subsequent function calls. Strings composed as described in Date Formats and Time Formats can be assigned to these variables, which affect only the current call. If the variables are not defined or set to an empty value then the Windows short date format (in the USA, normally mm/dd/yyyy) is used for date and the Windows short time format (in the USA, normally hh:mm:ss) for time values.

The date routines make use of non-business day information which has been set using the 'Set Non-Working Days' button on the Options page of the COPIAFACTS program (this data is recorded in FFCFG.INI in the base CopiaFacts folder). However if there is a file called HOLIDAYS.TXT in the CopiaFacts Application Data folder the routines will use Saturday and Sunday as normal non-working days and will read holiday information from this file. HOLIDAYS.TXT may contain up to 60 holiday dates in LOCAL date format and should only be used to specify holiday dates. This file is read in whenever COPIAFACTS starts and whenever the last modification date of the file has changed since the last function call.

For parameter values in single quotes which contain single-quote characters, the embedded single-quote character must be repeated.  See the description of $set_var for an example.


Topic url: http://www.copia.com/support/refmanual/index.html?functionsyntax.htm