Addn
The addn command adds a numerical value to a variable.
Syntax
Remarks
Because variables are 8 bit unsigned numbers, if the result of the addition exceeds 255, the result 'wraps around'. For example, if v50 currently equals 200, the statement:
addn(v50, 100);
will result in a value for v50 of 44 (200 + 100 = 300; 300 - 256 = 44). This can be represented mathematically as vA = (vA + B) % 0x100.
If the value of B is 1, WinAGI will use the increment command instead of addn if you use the alternate syntax (i.e. vA = vA + 1 or vA += 1). To force the compiler to use addn, use the full form: addn(vA, 1). This is important because the increment command does not wrap around like the addn command.
Possible Errors
None.
Example
<syntaxhighlight lang="agi"> v50 = 150; addn(v50, 75); [ v50 now equals 225 v50 = v50 + 75; [ v50 now equals 44 (300 - 256) v50 += 75; [ v50 now equals 119 </syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 5 (0x05 hex) |