Var » History » Version 3
  Per Amundsen, 02/28/2014 01:03 PM 
  
| 1 | 1 | Per Amundsen | _Added in 1.8.8_  | 
|---|---|---|---|
| 2 | |||
| 3 | */var [-sg] <%var> [[= ]value]*  | 
||
| 4 | |||
| 5 | Sets the value of local variable %var to the specified value.  | 
||
| 6 | |||
| 7 | *Switches*  | 
||
| 8 | |||
| 9 | -s - Display variable assignment value.  | 
||
| 10 | -g - Creates a global variable instead.  | 
||
| 11 | |||
| 12 | *Parameters*  | 
||
| 13 | |||
| 14 | <%var> - The variable to set.  | 
||
| 15 | [[= ]value] - Value to set the variable to. (can be a single arithmetic expression, see [[Arithmetic Operators]])  | 
||
| 16 | |||
| 17 | *Example*  | 
||
| 18 | |||
| 19 | 2 | Per Amundsen | <pre>  | 
| 20 | 3 | Per Amundsen | alias factorial { | 
| 21 | 1 | Per Amundsen | var %result = 1, %x = $1  | 
| 22 |   while (%x) { | 
||
| 23 | var %result = %result * $v1  | 
||
| 24 | dec %x  | 
||
| 25 | }  | 
||
| 26 | return %result  | 
||
| 27 | }  | 
||
| 28 | 3 | Per Amundsen | |
| 29 | ;Returns 3628800  | 
||
| 30 | //echo -ag $factorial(10)  | 
||
| 31 | 2 | Per Amundsen | </pre>  |