Difference between revisions of "Inc"

From Scriptwiki
Jump to: navigation, search
(added author)
(Deleted a sentence as the sense wasnt really clear :/ ('''Note''' that you can get same effect by using both increases and decreases switch z.))
Line 9: Line 9:
 
  c  - increases %var once per second.
 
  c  - increases %var once per second.
  
If no value is given, default value is 1
+
If no value is given, default value is 1.
'''Note''' that you can get same effect by using both increases and decreases switch z.
 
  
 
== Example ==
 
== Example ==
Line 53: Line 52:
 
== See Also ==
 
== See Also ==
  
[[dec]]
+
To decrease a value, you can also use [[dec]].
  
 
{{Author|Tovrleaf}}
 
{{Author|Tovrleaf}}
  
 
[[Category:Variables]]
 
[[Category:Variables]]

Revision as of 15:44, 16 October 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

Increase 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 advantages example, just playing around.

 1 alias exam_inc {
 2   set -s %x 1
 3   while (%x < 5) {
 4     inc -s %x
 5   }
 6   while (%x > 2) { 
 7     inc -s %x -1 
 8   } 
 9   inc -sz %x 2
10 }

Line numbers marked in comments. Displays

* 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