Use SET Instructions to Help Write Computations

Sometimes a SET instruction makes a computation easier to write. When there’s a long expression that is used in the computation more than once, set a variable to the expression and then use the variable wherever you need the expression after that in the computation.

For example, you might create a variable like Total Weight of Shipment just for use within the computation—it might not be used anywhere else in the template. In the following script, the SET instruction (the first instruction in the script) assigns the value of an entire expression to the variable. You can then use the variable elsewhere in the computation instead of writing the expression again:

SET Total Weight of Shipment TO (Weight of One Unit * Number of Units) + (Weight of Pallet * (Number of Units / 12))

IF Total Weight of Shipment > 10000

"Peoria Warehouse"

ELSE IF Total Weight of Shipment > 5000

"South Chicago Warehouse"

ELSE IF Total Weight of Shipment > 200

"Chicago Office Warehouse"

ELSE

"Local Office"

END IF