Explicitly declares a variable type.
DECLARE-VARIABLE [DEFAULT-NUMERIC={DECIMAL[(prec_lit)]|FLOAT|INTEGER}] [DECIMAL[(prec_lit)]num_var[(prec_lit)][num_var[(prec_lit)]]...] [FLOAT num_var[num_var]...] [DATE date_var[date_var]...] [INTEGER num_var[num_var]...] [TEXT string_var[string_var]...] [BINARY binary_var[binary_var]...] END-DECLARE
Default type for numeric variables. Unless explicitly declared otherwise, a numeric variable assumes the variable type. This qualifier overrides any setting from the command-line flag ‑DNT or the DEFAULT-NUMERIC entry in the [Default-Settings] section of SQR.INI. If ‑DNT was not specified on the command line and SQR.INI has no DEFAULT-NUMERIC entry, then the default numeric type is FLOAT.
Defines that the numeric variables that follow are decimal variables with a precision specified with prec_lit. The precision can be assigned to the group of variables or to each individual variable. The precision is the total number of digits used to represent the number. This precision can range from 1 to 38. The default value is 16. The range of decimal numbers is from ‑9.9999999999999999999999999999999999999E±4096 to +9.9999999999999999999999999999999999999E±4096
Defines that the numeric variables that follow are used as double precision floating point. The range and precision of these numbers are machine- dependent.
Defines that the date variables that follow can contain a date in the range of January1,4713 BC to December 31, 9999 AD.
Defines that the numeric variables that follow are used as integers with a range of ‑2147483648 to +2147483647.
Defines that the string variables that follow are text (character) variables.
Defines that the variables that follow support BINARY data.
You can set the default numeric type externally, using the -DNT command-line flag or the DEFAULT-NUMERIC setting in the [Default-Settings] section of SQR.INI. However, the setting in DECLARE-VARIABLE takes precedence over all other settings. If the command has not been used, then the -DNT command-line flag takes precedence over the setting in SQR.INI.
Besides FLOAT, INTEGER, or DECIMAL, the DEFAULT-NUMERIC setting in SQR.INI and -DNT command-line flag can be set to V30. With V30, the program acts in the same manner as in pre-version 4.0 releases; that is, all variables are FLOAT. Incidentally, V30 is not a valid setting for the DEFAULT‑NUMERIC setting in DECLARE-VARIABLE.
DECLARE-VARIABLE allows the user to determine the type of variables to use to fit their needs. This command can only appear in the SETUP section or as the first statement of a local procedure. The placement of the command affects its scope. When used in the SETUP section, it affects all variables in the entire program. Alternately, when it is placed in a local procedure, its effect is limited to the scope of the procedure. If the command is in both places, the local declaration takes precedence over the SETUP declaration.
In addition to declaring variables, the command allows the default numeric type to be specified using the DEFAULT-NUMERIC setting as FLOAT, INTEGER, or DECIMAL. When dealing with money or where more precision is required, you can use the DECIMAL qualifier.
DECLARE-VARIABLE, the -DNT command-line flag, and the DEFAULT-NUMERIC setting in SQR.INI affects the way numeric literals are typed. If V30 is specified, then all numeric literals are FLOAT (just as in pre-version 4.0 releases); otherwise, the use or lack of a decimal point determines the type of the literal as either FLOAT or INTEGER, respectively. Finally, not specifying DECLARE‑VARIABLE, the -DNT command-line flag, and the DEFAULT‑NUMERIC setting in SQR.INI is the same as specifying V30.
begin-setup declare-variable default-numeric=float decimal #decimal(10) integer #counter date $date end-declare end-setup . . let $date = strtodate('Jan 01 1995','Mon DD YYYY') print $date (1,1) position (+2,1)
let #counter = 0 while #counter < 10 let #decimal = sqrt(#counter) add 1 to counter print #decimal (+1,1) 9.999999999 end-while
do sub1($date, 'day', 10) do sub2
. . begin-procedure sub1(:$dvar, $units, #uval) declare-variable date $dvar integer #uval end-declare let $dvar = dateadd($dvar, $units, #uval) print $dvar (+1,1) position (+2,1) end-procedure . . begin-procedure sub2 LOCAL declare-variable date $mydate end-declare let $mydate = dateadd($_date, 'year', 5) print $mydate (+1,1) position (+2,1) end-procedure . .
The -DNT command-line flag, described in Introduction.
The [Default-Settings] section of SQR.INI described in SQR.INI.