setvar

Syntax

code = SETVAR(variable, value)

Arguments

code: integer

variable, value: text

Meaning

SETVAR assigns the string value to the custom system variable variable. The code is 0 if the action was successful. It is also perfectly allowed to empty a system variable by assigning an empty value, so this counts as a successful action as well; code 1 means the action was unsuccessful (with reason unknown).
System (aka environment) variables are not variables defined by the system (although Collections defines a number of reserved system variables for you implicitly), you define them here with SETVAR in the system (temporarily, during the adapl session, not permanently), so the variable can have almost any name (without spaces) you choose. However, they are primarily meant for internal use by the Collections software, to pass different kinds of status information to the adapl interpreter. So there are a number of reserved system variables, like the variables starting with an & (such as the commonly used &E to obtain FACS function result codes to decide what to do next) and the ADLIB_SMARTHOST variable which must contain the name of your SMTP server if the adapl must be capable of sending e-mails. Normally you don't assign any values to the reserved variables starting with an &, because Collections fills them for you, but you must assign the name of your SMTP server to the ADLIB_SMARTHOST variable explicitly in the adapl from which you want to be able to send e-mails.

Example 1

smarthost_result = setvar('ADLIB_SMARTHOST', text$(192))

Result

This is the typical ADLIB_SMARTHOST assignment, which can be found in some adapls. The name of your SMTP server must be stored in line 192 of the adlib#.txt files in the \texts subfolder of your Collections system. However, whether you have done that or not, smarthost_result will be zero in either case. So to test for the presence of an SMTP server name, you must test if text$(192) is empty or filled.

Example 2

smarthost_result = setvar('ADLIB_SMARTHOST', '')

Result

This assignment empties the ADLIB_SMARTHOST variable and smarthost_result will be zero if it succeeds.

Example 3

code = setvar('LAST_ORDER', '17-07-1994-DBX')

Result

code will be 0 if the value '17-07-1994-DBX' is successfully assigned to the system variable LAST_ORDER.

See also

GETVAR