SET

SET

Top  Previous  Next

 

The SET command sets a value into an @-variable.

 

 

Format

 

SET variable  value

SET variable EVAL expression

 

where

 

variableis the name of the variable to be set. The leading @ character is optional. The name may be up to 32 characters and is case insensitive.

 

valueis the value to be stored. This may not include the mark characters. Quotes should not be used unless they are part of the value to be stored. Leading and trailing spaces within value are removed; embedded spaces are retained.

 

expressionis an arithmetic expression to be evaluated.

 

 

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.