|
|
|
Online Scripting Reference
|
|
subtract
|
Purpose
|
Subtracts a value from a variable.
|
|
Syntax
|
subtract var {value}
var: The variable that will be subtracted from.
{value}: The amount the variable will be subtracted by (must be a number).
|
|
Notes
|
This command is a typical way to perform basic mathematics within TWX script.
Since mathematical and logical operators were introduced in v2.00, it is also possible to subtract from a variable using the following method:
setVar $value ($value - 1)
|
|
Example
|
# calculate exactly how many trips we're making
# and how much we're carrying on our last trip
setVar $trips $quantity
divide $trips $holds
setVar $x $trips
multiply $x $holds
setVar $lastTrip $quantity
subtract $lastTrip $x
if ($lastTrip = 0)
setVar $lastTrip $holds
else
add $trips 1
end
|
Return to item listing |
|
|