Any set command must be of the following format:
set container operator value
The set command enables you to modify the current value of the specified container. A container is either an object element (see the chapter Definitions in Detail for more information), a variable or an item pointer such as noun1 or here. The value can be an integer, integer constant or any other container whose value you wish to copy.
The following is a list of operators that can be used with the set command:
| Operator | Description |
|---|---|
| = | Set the value of the specified container to the specified value. |
| + | Add the specified value to the current value of the specified container. |
| - | Subtract the specified value from the current value of the specified container. |
| / | Divide the current value of the specified container by the specified value. |
| * | Multiply the current value of the specified container by the specified value. |
Like many other JACL commands, the set command accepts only a fixed number of parameters. For this reason, complex expressions must be evaluated using several steps. For example, to add 7 and 9 then divide the result by 4, you must create a variable, then use the following code:
variable TEMP
{+maths
set TEMP = 7 ;Sets the current value of TEMP to 7
set TEMP + 9 ;Adds 9 to the current value of TEMP
set TEMP / 4 ;Divides the current value of TEMP by 4
}
![]() |
Although all JACL commands require whitespace between each parameter, it is especially easy to forget the space between the container and the operator or the operator and the value. It is, of course, valid to have a command such as:
set BANK_BALANCE = -42 |
Rigid type enforcement is considered a highly-desirable strength in a modern programming language. I consider it a pain in the arse. All the possible expressions that can be given for value in a set statement resolve to a single integer. Due to this fact, there are no real issues with type casting in JACL, and all of following commands are perfectly valid:
set VARIABLE = small_frog
set noun4 = VARIABLE
set noun4 + 1 ; NOTE: noun4 will now equal the item defined
; directly after small_frog in the game file.
set lantern(status) = noun1(parent)
set sword(parent) = random
![]() |
The only real potential danger in the above examples it that of setting one of the object pointers to a value less than one, or greater than the internal number of the last object. |