Var » History » Version 10
Per Amundsen, 07/20/2014 08:40 AM
1 | 1 | Per Amundsen | _Added in 1.8.8_ |
---|---|---|---|
2 | |||
3 | 10 | Per Amundsen | */var [-gns] <%var> [[= ]value]* |
4 | 1 | Per Amundsen | |
5 | Sets the value of local variable %var to the specified value. |
||
6 | |||
7 | 6 | Per Amundsen | Syntax can be either _var %var = value_ or _var %var value_. |
8 | 5 | Per Amundsen | |
9 | 9 | Per Amundsen | Multiple variables can be set in one line using comma as separator, _var %var1 = value, %var2 = value2_. |
10 | 5 | Per Amundsen | |
11 | 1 | Per Amundsen | *Switches* |
12 | |||
13 | -s - Display variable assignment value. |
||
14 | -g - Creates a global variable instead. |
||
15 | 4 | Per Amundsen | -n - Treat the value as plain text, even if arithmetic operators are used. |
16 | 1 | Per Amundsen | |
17 | *Parameters* |
||
18 | |||
19 | <%var> - The variable to set. |
||
20 | [[= ]value] - Value to set the variable to. (can be a single arithmetic expression, see [[Arithmetic Operators]]) |
||
21 | |||
22 | *Example* |
||
23 | |||
24 | 2 | Per Amundsen | <pre> |
25 | 3 | Per Amundsen | alias factorial { |
26 | 1 | Per Amundsen | var %result = 1, %x = $1 |
27 | while (%x) { |
||
28 | var %result = %result * $v1 |
||
29 | dec %x |
||
30 | } |
||
31 | return %result |
||
32 | } |
||
33 | 3 | Per Amundsen | |
34 | ;Returns 3628800 |
||
35 | //echo -ag $factorial(10) |
||
36 | 2 | Per Amundsen | </pre> |