Project

General

Profile

Testasd » History » Version 63

Per Amundsen, 02/08/2023 09:33 AM

1 45 Per Amundsen
h1. Multidimensional arrays
2
3 62 Per Amundsen
*/marray -aTNBAV <name> [N..] <item> <value>*
4 45 Per Amundsen
5
add item
6
7 62 Per Amundsen
*/marray -eTNBAV <name> [N..] <N> <item> <value>*
8 45 Per Amundsen
9
edit item
10 1 Per Amundsen
11 62 Per Amundsen
*/marray -iTNBAV <name> [N..] <N> <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 1 Per Amundsen
21
delete/free table
22
23 62 Per Amundsen
*Switches*
24
25
-T - Indicates the type is text.
26
-N - Indicates the type is a number.
27
-B - Indicates the type is a boolean.
28
-A - Indicates the type is a sub table/array.
29
-V - TODO Indicates the type is a binvar..
30
31 50 Per Amundsen
*$marray(name, N, [N..])*
32 1 Per Amundsen
33 45 Per Amundsen
gets the Nth item in a table, subsequent N parameters gets the Nth item from a sub table, infinite sub depth.
34
35 1 Per Amundsen
*Switches*
36 49 Per Amundsen
37 60 Per Amundsen
.item - Get item.
38 55 Per Amundsen
.value - Get item value.
39 62 Per Amundsen
.type - Get item type. (0 = text, 1 = number, 2 = bool, 3 = binvar, 4 = sub table)
40 55 Per Amundsen
.json - Generate a json table from all items in the current table and all sub tables.
41
.ini - Generate a ini output from all items in the current table and all sub tables.
42 63 Per Amundsen
.xml - Generate a xml output from all items in the current table and all sub tables.
43 1 Per Amundsen
44
*Example*
45 56 Per Amundsen
46 1 Per Amundsen
<pre>
47 56 Per Amundsen
; Add item1/value1 to the table 'table1'.
48 62 Per Amundsen
//marray -a table1 item1 value1
49 56 Per Amundsen
50 62 Per Amundsen
; Add sub table 'item2' to the table 'table1'.
51
//marray -aA table1 item2 value2
52 57 Per Amundsen
53 55 Per Amundsen
; Insert item3/value3 at position '1' in the table 'table1'.
54 62 Per Amundsen
//marray -i table1 1 item3 value3
55 55 Per Amundsen
56
; Print number of items in table 'table1'.
57
//echo -ag Number of items in table1 is $marray(table1, 0)
58
59
; Print the first items in table 'table1'.
60 1 Per Amundsen
//echo -ag First item in table1 is $marray(table1, 1).item
61 55 Per Amundsen
62 1 Per Amundsen
; Delete the first item in table 'table1'.
63 55 Per Amundsen
//marray -d table1 1
64
65
; Free the table 'table1'.
66
//marray -f table1
67
68
; Add a new sub table to table 'table1',
69 62 Per Amundsen
//marray -aA table1 sub1 sub1
70 55 Per Amundsen
71 56 Per Amundsen
; Add a new item to the sub table located at position '1' in table 'table1'.
72 62 Per Amundsen
//marray -a table1 1 item1 value1
73 55 Per Amundsen
74
; Print the first item in the table 'table1', which is a sub table.
75
//echo -ag First item in table1 is $marray(table1, 1).item - $marray(table1, 1).type
76
77
; Print the first item in the sub table located at position '1' in table 'table1'.
78
//echo -ag First item in sub table1 is $marray(table1, 1, 1).item
79 63 Per Amundsen
80
; Generates a json output of table 'table1'.
81
// echo -ag $marray(table1).json
82
83
; Generates a ini output of table 'table1'.
84
// echo -ag $marray(table1).ini
85
86
; Generates a xml output of sub at position '1' in table 'table1'.
87
// echo -ag $marray(table1, 1).xml
88 1 Per Amundsen
</pre>