Project

General

Profile

Testasd » History » Version 66

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

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