Decrement
From AGI Wiki
Jump to navigationJump to searchThe decrement command decreases a variable's value by one.
Syntax
decrement(var vA);
--vA;
vA--;
vA = vA - 1;
vA -= 1;
Remarks
Unlike the subn command, the decrement command does not wrap around. If the value of vA is already 0, executing the decrement command has no effect; the value will remain at 0.
When using the alternate syntax vA = vA - 1;
WinAGI will compile a decrement command. If you specifically want to use the subn command, you must use the full command syntax (subn(vA, 1);
).
Possible Errors
None.
Example
Code:
<syntaxhighlight lang="agi"> v50 = 1; decrement(v50); [ v50 now equals 0 --v50; [ v50 still equals 0 v50 = v50 - 1; [ WinAGI compiles this as a decrement command so v50 still equals 0 subn(v50,1); [ now v50 equals 255 </syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 2 (0x02 hex) |