$calias » History » Version 9
Per Amundsen, 02/16/2023 09:18 PM
1 | 1 | Per Amundsen | _Added in 2.4_ |
---|---|---|---|
2 | |||
3 | *$calias* |
||
4 | |||
5 | Returns the calling alias for the current script, |
||
6 | |||
7 | <pre> |
||
8 | alias test1 { |
||
9 | echo -ag Calling alias is $calias |
||
10 | noop $test2 |
||
11 | } |
||
12 | |||
13 | alias test2 { |
||
14 | echo -ag Calling alias is still $calias |
||
15 | noop $test3 |
||
16 | } |
||
17 | |||
18 | alias test3 { |
||
19 | echo -ag Calling alias is still $calias |
||
20 | } |
||
21 | </pre> |
||
22 | 2 | Per Amundsen | |
23 | --- |
||
24 | |||
25 | _Added in 2.7_ |
||
26 | |||
27 | *$calias(N)* |
||
28 | |||
29 | 6 | Per Amundsen | Returns the Nth calling alias in the scripting stack. |
30 | 2 | Per Amundsen | |
31 | *Parameters* |
||
32 | |||
33 | 9 | Per Amundsen | table(ktable). |
34 | |*Parameter*|*Description*| |
||
35 | | N | If N = 0, number of aliases in the stack, otherwise the Nth calling alias. | |
||
36 | 1 | Per Amundsen | |
37 | *Properties* |
||
38 | |||
39 | 9 | Per Amundsen | table(ktable). |
40 | |*Property*|*Description*| |
||
41 | | .alias | Returns the name of the alias. | |
||
42 | | .fname | Returns the filename of the script calling the alias. | |
||
43 | | .line | Returns the line number in the script calling the alias. | |
||
44 | | .isid | Returns [[$true]] if the alias was called as a identifier, otherwise [[$false]]. | |
||
45 | 2 | Per Amundsen | |
46 | *Example* |
||
47 | |||
48 | <pre> |
||
49 | alias alias1 { |
||
50 | alias2 |
||
51 | } |
||
52 | |||
53 | alias alias2 { |
||
54 | noop $alias3 |
||
55 | } |
||
56 | |||
57 | alias alias3 { |
||
58 | var %s 0 |
||
59 | while (%s < $calias(0)) { |
||
60 | inc %s |
||
61 | 5 | Per Amundsen | linesep |
62 | |||
63 | var %alias $calias(%s).alias |
||
64 | echo -ag alias = %alias |
||
65 | echo -ag calling filename = $calias(%s).fname |
||
66 | echo -ag caling line = $calias(%s).line |
||
67 | 1 | Per Amundsen | echo -ag isid = $calias(%s).isid |
68 | 5 | Per Amundsen | |
69 | if ($isalias(%alias)) { |
||
70 | echo -ag alias filename = $isalias(%alias).fname |
||
71 | echo -ag alias line = $isalias(%alias).fline |
||
72 | echo -ag alias type = $isalias(%alias).ftype |
||
73 | } |
||
74 | |||
75 | linesep |
||
76 | 2 | Per Amundsen | } |
77 | } |
||
78 | </pre> |