Inc: Difference between revisions
Jump to navigation
Jump to search
m little tweak |
removed line numbers, /inc'ed grammar |
||
Line 13: | Line 13: | ||
== Example == | == Example == | ||
The /inc command is commonly used in [[While_loops|loops]]. | |||
var %c = 1 | var %c = 1 | ||
while (%c <= 4) { | while (%c <= 4) { | ||
Line 22: | Line 22: | ||
Displays %c's values from 1 to 4. | Displays %c's values from 1 to 4. | ||
More | More advanced example, just playing around. | ||
alias exam_inc { | |||
[[set]] -s %x 1 | |||
while (%x < 5) { | |||
inc -s %x | |||
} | |||
while (%x > 2) { | |||
inc -s %x -1 | |||
} | |||
inc -sz %x 2 | |||
} | |||
In the following results the line numbers are added after ;. The results are: | In the following results the line numbers are added after ;. The results are: | ||
* Set %x to 1 ; 1 | * Set %x to 1 ; 1 | ||
* Inc %x to 2 ; 2-5 | * Inc %x to 2 ; 2-5 | ||
* Inc %x to 3 ; 2-5 | * Inc %x to 3 ; 2-5 | ||
* Inc %x to 4 ; 2-5 | * Inc %x to 4 ; 2-5 | ||
* Inc %x to 5 ; 2-5 | * Inc %x to 5 ; 2-5 | ||
* Inc %x to 4 ; 6-8 | * Inc %x to 4 ; 6-8 | ||
* Inc %x to 3 ; 6-8 | * Inc %x to 3 ; 6-8 | ||
* Inc %x to 2 ; 6-8 | * Inc %x to 2 ; 6-8 | ||
* Inc %x to 4 ; 9 (notice increase with 2) | * Inc %x to 4 ; 9 (notice increase with 2) | ||
* Inc %x to 3 ; 9 | * Inc %x to 3 ; 9 | ||
* Inc %x to 2 ; 9 | * Inc %x to 2 ; 9 | ||
* Inc %x to 1 ; 9 | * Inc %x to 1 ; 9 | ||
* Unset %x | * Unset %x ; 9 (switch z unsets) | ||
== See Also == | == See Also == |
Revision as of 14:10, 10 November 2005
This increases the value of %var by value.
/inc [-cszuN] <%var> [value]
Options explained:
uN - increases %var once and unsets it N seconds later. z - decreases %var until it reaches zero and then unsets it. s - displays action in status window c - increases %var once per second.
If no value is given, default value is 1.
Example
The /inc command is commonly used in loops.
var %c = 1 while (%c <= 4) { ; do something ; continue, commands etc.. inc %c }
Displays %c's values from 1 to 4. More advanced example, just playing around.
alias exam_inc { set -s %x 1 while (%x < 5) { inc -s %x } while (%x > 2) { inc -s %x -1 } inc -sz %x 2 }
In the following results the line numbers are added after ;. The results are:
* Set %x to 1 ; 1 * Inc %x to 2 ; 2-5 * Inc %x to 3 ; 2-5 * Inc %x to 4 ; 2-5 * Inc %x to 5 ; 2-5 * Inc %x to 4 ; 6-8 * Inc %x to 3 ; 6-8 * Inc %x to 2 ; 6-8 * Inc %x to 4 ; 9 (notice increase with 2) * Inc %x to 3 ; 9 * Inc %x to 2 ; 9 * Inc %x to 1 ; 9 * Unset %x ; 9 (switch z unsets)
See Also
To decrease a value, you can also use dec.
Contributed by Tovrleaf |