Project

General

Profile

Mtable » History » Version 4

Per Amundsen, 02/22/2023 06:04 AM

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