$var » History » Version 4
Per Amundsen, 02/26/2017 06:54 PM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | *$var(%var,[N])* |
||
4 | |||
5 | Returns the Nth matching variable name. |
||
6 | |||
7 | 3 | Per Amundsen | _Searches both local and global variables, wildcards can be used._ |
8 | 1 | Per Amundsen | |
9 | *Parameters* |
||
10 | |||
11 | %var - Variable to match. |
||
12 | [N] - If N = 0, number of matched variables (default), otherwise the Nth match. (optional) |
||
13 | |||
14 | *Properties* |
||
15 | |||
16 | .value - The variable value. |
||
17 | .local - [[$true]] if the variable is a local variable, otherwise [[$false]]. |
||
18 | .secs - Number of seconds until the variable is unset (if autounset is on). |
||
19 | |||
20 | *Examples* |
||
21 | |||
22 | <pre> |
||
23 | 4 | Per Amundsen | ; Create a variable. |
24 | 1 | Per Amundsen | /set %Example Hello World |
25 | |||
26 | 4 | Per Amundsen | ; Print number of variables matching '%Example*'. |
27 | 1 | Per Amundsen | //echo -ag $var(%Example*, 0) |
28 | |||
29 | ; Print the name and value from the first match. |
||
30 | //echo -ag $var(%Example*, 1) = $var(%Example*, 1).value |
||
31 | 2 | Per Amundsen | |
32 | ; Delete the variable |
||
33 | /unset %Example |
||
34 | 1 | Per Amundsen | </pre> |