Var » History » Version 12
Per Amundsen, 11/18/2018 03:04 AM
1 | 1 | Per Amundsen | _Added in 1.8.8_ |
---|---|---|---|
2 | |||
3 | 12 | Per Amundsen | */var [-gnsp] <%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 | -n - Treat the value as plain text, even if arithmetic operators are used. |
||
16 | 12 | Per Amundsen | -p - TODO |
17 | 1 | Per Amundsen | |
18 | *Parameters* |
||
19 | |||
20 | <%var> - The variable to set. |
||
21 | 11 | Per Amundsen | [[= ]value] - Value to set the variable to. (can be a single [[Arithmetic Operators|arithmetic expression]]) |
22 | 1 | Per Amundsen | |
23 | *Example* |
||
24 | |||
25 | 2 | Per Amundsen | <pre> |
26 | 3 | Per Amundsen | alias factorial { |
27 | 1 | Per Amundsen | var %result = 1, %x = $1 |
28 | while (%x) { |
||
29 | var %result = %result * $v1 |
||
30 | dec %x |
||
31 | } |
||
32 | return %result |
||
33 | } |
||
34 | 3 | Per Amundsen | |
35 | ;Returns 3628800 |
||
36 | //echo -ag $factorial(10) |
||
37 | 2 | Per Amundsen | </pre> |