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