Project

General

Profile

Mtable » History » Version 1

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