Project

General

Profile

Mtable » History » Version 2

Per Amundsen, 02/12/2023 10:14 AM

1 1 Per Amundsen
_Added in 4.4_
2
3
*/mtable -aTNBAV <name> [N..] <item> <value>*
4
*/mtable -eTNBAV <name> [N..] <N> <item> <value>*
5
*/mtable -iTNBAV <name> [N..] <N> <item> <value>*
6
*/mtable -d <name> [N..] <N>*
7
*/mtable -f <name>*
8
9
Adds/removes/inserts/modifies items in a multi dimensional table/array.
10
11 2 Per Amundsen
Items are not unique and the table is always ordered based on the N position in the table.
12
13 1 Per Amundsen
_See also [[$mtable]]._
14
15
*Parameters*
16
17
<name> - Name of the table to modify.
18
[N..] - Indicates the item should be added/inserted/deleted from sub table at position N, subsequent N parameters travels further down.
19
<N> - The Nth item in a table or sub table to modify.
20
<item> - The item name.
21
<value> - The item value.
22
23
*Switches*
24
25
-a - Add a new item to a table.
26
-e - Edit a item in a table.
27
-i - Insert a new item to a table.
28
-d - Delete a item from a table.
29
-f - Free/delete a table.
30
-T - Indicates the type is text.
31
-N - Indicates the type is a number.
32
-B - Indicates the type is a boolean.
33
-A - Indicates the type is a sub table/array.
34
35
*Example*
36
37
<pre>
38
; Add item1/value1 to the table 'table1'.
39
//mtable -a table1 item1 value1
40
41
; Add sub table 'item2' to the table 'table1'.
42
//mtable -aA table1 item2 value2
43
44
; Insert item3/value3 at position '1' in the table 'table1'.
45
//mtable -i table1 1 item3 value3
46
47
; Print number of items in table 'table1'.
48
//echo -ag Number of items in table1 is $mtable(table1, 0)
49
50
; Print the first items in table 'table1'.
51
//echo -ag First item in table1 is $mtable(table1, 1).item
52
53
; Delete the first item in table 'table1'.
54
//mtable -d table1 1
55
56
; Free the table 'table1'.
57
//mtable -f table1
58
59
; Add a new sub table to table 'table1',
60
//mtable -aA table1 sub1 sub1
61
62
; Add a new item to the sub table located at position '1' in table 'table1'.
63
//mtable -a table1 1 item1 value1
64
65
; Print the first item in the table 'table1', which is a sub table.
66
//echo -ag First item in table1 is $mtable(table1, 1).item - $mtable(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 $mtable(table1, 1, 1).item
70
71
; Generates a json output of table 'table1'.
72
// echo -ag $mtable(table1).json
73
74
; Generates a ini output of table 'table1'.
75
// echo -ag $mtable(table1).ini
76
77
; Generates a xml output of sub table at position '1' in table 'table1'.
78
// echo -ag $mtable(table1, 1).xml
79
</pre>