Type
Procedural Command
Purpose
The optional assign command is used to give a value to a temporary or global variable. A variable is used to store a value, such as a text string or a calculated result, that can change during the processing of a procedure. By specifying the variable's name, the stored value can be used like any other value in a script.
The status of a variable can be global (denoted by the keyword global) or temporary (denoted by the keyword temp). A temporary variable can only maintain a value during the current procedure. A global variable can pass its value from one procedure to another. To pass a value from one procedure to another, the variable must be defined identically in each procedure.
Syntax
assign global|temp VARIABLE NAME := ASSIGNED VALUE .
Usage
The assign command is followed by:
- The status of the variable (global or temporary).
- The name of the variable (without quotation marks).
- The assignment operator.
- The value assigned to the variable.
- A period.
Example
define temp "DISCOUNT" Number .
for RESERVATIONS with TOTAL DUE > 2000 ;
assign temp DISCOUNT := RESERVATIONS
TOTAL DUE * 0. 15 .
modify records
TOTAL DUE := TOTAL DUE ⌀ temp DISCOUNT .
end
This script tells DataEase: 1) Create (define) a temporary variable called DISCOUNT to store a number while processing the current script. 2) Find all the RESERVATIONS records that have a value greater than 2000 in the TOTAL DUE field. 3) Give (assign) the DISCOUNT variable a number value determined by multiplying the TOTAL DUE on each reservation by 15%. 4) Modify these RESERVATIONS records by subtracting the value of the DISCOUNT variable from the value in the TOTAL DUE field.