-
Notifications
You must be signed in to change notification settings - Fork 8
Add
MicroBlaster edited this page Oct 3, 2017
·
4 revisions
Purpose: Adds a value to a variable.
Syntax: add var {value}
var: The variable that will have its value added to.
{value}: The amount the variable will be increased 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 add to 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.