SET |
|
|
The SET command sets a value into an @-variable.
Format
SET variable value SET variable EVAL expression
where
The SET command sets a value into a user defined @-variable. The values of system defined variables @SYSTEM.RETURN.CODE, @USER0 to @USER4 and @USER.RETURN.CODE can also be set.
In the second form, the expression may include the four arithmetic operators +, -, * and /. These operators must be surrounded by spaces. Any @-variables in the expression will be expanded.
Examples
SET USER.RETURN.CODE 1
The above command sets the @USER.RETURN.CODE variable to 1.
PA SET CT 5 LOOP DISPLAY <<@CT>> SET CT EVAL @CT - 1 IF @CT = 0 THEN STOP REPEAT
This paragraph executes the loop five times, displaying the decreasing values stored in @CT on each cycle.
PA SET @PRINT "" IF <<I2,Select branch>> EQ "" THEN STOP IF <<I3,Print (Y/N)?>> EQ "Y" THEN SET @PRINT LPTR LIST LOANS WITH BRANCH EQ "<<Select branch>>" _ BY NAME PAN SCROLL TITLE DATE NAME ID.SUP <<@PRINT>>
The above paragraph shows use of a user defined @-variable to control whether the paragraph directs the report to the display or to a printer. The @PRINT variable is set to a null string at the start of the paragraph in case it already exists from previous actions in the same session. Later, if the user wants the report sent to a printer, this variable is set to "LPTR". The value of @PRINT is then included in the query sentence executed by the paragraph.
See also: LIST.VARS and the QMBasic !ATVAR() and !SETVAR() subroutines. |