It is possible to use the subtraction operator in a normal manner, where the result of the subtraction is used with another operator or as a parameter to a command, or in the shortcut mode shown in the previous page. The same restrictions apply as with the addition operator: the result of the calculation must not be used and the leftmost item must be a variable (so that it can be decreased).
This example demonstrates some of the uses of the subtraction operator. You can get the source here.
OpenConsole()
; Part 1 - Simple example of using the subtraction operator
x2 = 50
x1 = 25
distance = x2 - x1
PrintN("Distance between two points: " + Str(distance))
; Part 2 - Multiple operators can be used in the same calculation
total = 100
half = 50
quarter = 25
tenth = 10
leftovers = total - half - quarter - tenth - 2
PrintN("Remaining quantity: " + Str(leftovers))
; Part 3 - Shortcut version of the subtraction operator
leftovers - 3
PrintN("After decreasing using shortcut method: " + Str(leftovers))
PrintN("Press return to exit")
Input()
CloseConsole()
End
This image shows the output of the example program.
| Previous topic | Chapter contents | Next topic |
|---|---|---|
| Addition | User Guide contents | Multiplication and Division |