Decrement
From AGI Wiki
Revision as of 19:42, 29 March 2019 by Andrew Korson (talk | contribs) (Created page with "The '''decrement''' command decreases a variable's value by one. == Syntax == decrement(var vA);<br /> --vA;<br /> vA--;<br /> vA = vA - 1;<br /> vA -= 1;<br />...")
The 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) |