$mtable » History » Version 1
Per Amundsen, 02/12/2023 07:47 AM
1 | 1 | Per Amundsen | _Added in 4.4_ |
---|---|---|---|
2 | |||
3 | *$mtable(name, N, [N..])* |
||
4 | |||
5 | Gets the Nth item in a table, subsequent N parameters gets the Nth item from a sub table, infinite sub depth. |
||
6 | |||
7 | _See also [[/mtable]]._ |
||
8 | |||
9 | *Parameters* |
||
10 | |||
11 | name - The outer table name. |
||
12 | N - The Nth item in the table. |
||
13 | [N..] - The Nth item in a sub table, subsequent N parameters travels further down. |
||
14 | |||
15 | *Properties* |
||
16 | |||
17 | .item - Gets the item name. |
||
18 | .value - Gets the item value. |
||
19 | .type - Get the item type. (0 = text, 1 = number, 2 = bool, 3 = sub table) |
||
20 | .json - Generate a json table from all items in the current table and all sub tables. |
||
21 | .ini - Generate a ini output from all items in the current table and all sub tables. |
||
22 | .xml - Generate a xml output from all items in the current table and all sub tables. |
||
23 | |||
24 | <pre> |
||
25 | ; Add item1/value1 to the table 'table1'. |
||
26 | //mtable -a table1 item1 value1 |
||
27 | |||
28 | ; Add sub table 'item2' to the table 'table1'. |
||
29 | //mtable -aA table1 item2 value2 |
||
30 | |||
31 | ; Insert item3/value3 at position '1' in the table 'table1'. |
||
32 | //mtable -i table1 1 item3 value3 |
||
33 | |||
34 | ; Print number of items in table 'table1'. |
||
35 | //echo -ag Number of items in table1 is $mtable(table1, 0) |
||
36 | |||
37 | ; Print the first items in table 'table1'. |
||
38 | //echo -ag First item in table1 is $mtable(table1, 1).item |
||
39 | |||
40 | ; Delete the first item in table 'table1'. |
||
41 | //mtable -d table1 1 |
||
42 | |||
43 | ; Free the table 'table1'. |
||
44 | //mtable -f table1 |
||
45 | |||
46 | ; Add a new sub table to table 'table1', |
||
47 | //mtable -aA table1 sub1 sub1 |
||
48 | |||
49 | ; Add a new item to the sub table located at position '1' in table 'table1'. |
||
50 | //mtable -a table1 1 item1 value1 |
||
51 | |||
52 | ; Print the first item in the table 'table1', which is a sub table. |
||
53 | //echo -ag First item in table1 is $mtable(table1, 1).item - $mtable(table1, 1).type |
||
54 | |||
55 | ; Print the first item in the sub table located at position '1' in table 'table1'. |
||
56 | //echo -ag First item in sub table1 is $mtable(table1, 1, 1).item |
||
57 | |||
58 | ; Generates a json output of table 'table1'. |
||
59 | // echo -ag $mtable(table1).json |
||
60 | |||
61 | ; Generates a ini output of table 'table1'. |
||
62 | // echo -ag $mtable(table1).ini |
||
63 | |||
64 | ; Generates a xml output of sub table at position '1' in table 'table1'. |
||
65 | // echo -ag $mtable(table1, 1).xml |
||
66 | </pre> |