Mtable » History » Version 6
  Per Amundsen, 08/12/2023 07:04 PM 
  
| 1 | 1 | Per Amundsen | _Added in 4.4_ | 
|---|---|---|---|
| 2 | |||
| 3 | 5 | Per Amundsen | */mtable -aTNAVB <name> [N..] <item> <value>* | 
| 4 | */mtable -eTNAVB <name> [N..] <N> <item> <value>* | ||
| 5 | */mtable -iTNAVB <name> [N..] <N> <item> <value>* | ||
| 6 | 6 | Per Amundsen | */mtable -lJXI <name> <file>* | 
| 7 | */mtable -sJXI <name> <file>* | ||
| 8 | 1 | Per Amundsen | */mtable -d <name> [N..] <N>* | 
| 9 | */mtable -f <name>* | ||
| 10 | |||
| 11 | Adds/removes/inserts/modifies items in a multi dimensional table/array. | ||
| 12 | |||
| 13 | 2 | Per Amundsen | Items are not unique and the table is always ordered based on the N position in the table. | 
| 14 | |||
| 15 | 1 | Per Amundsen | _See also [[$mtable]]._ | 
| 16 | |||
| 17 | *Parameters* | ||
| 18 | |||
| 19 | 3 | Per Amundsen | table(ktable). | 
| 20 | |*Parameter*|*Description*| | ||
| 21 | | <name> | Name of the table to modify. | | ||
| 22 | | [N..] | Indicates the item should be added/inserted/deleted from sub table at position N, subsequent N parameters travels further down. | | ||
| 23 | | <N> | The Nth item in a table or sub table to modify. | | ||
| 24 | | <item> | The item name. | | ||
| 25 | | <value> | The item value. | | ||
| 26 | 1 | Per Amundsen | |
| 27 | *Switches* | ||
| 28 | |||
| 29 | 3 | Per Amundsen | table(ktable). | 
| 30 | |*Switch*|*Description*| | ||
| 31 | | -a | Add a new item to a table. | | ||
| 32 | | -e | Edit a item in a table. | | ||
| 33 | | -i | Insert a new item to a table. | | ||
| 34 | | -d | Delete a item from a table. | | ||
| 35 | 6 | Per Amundsen | | -l | Loads a table from a file. | | 
| 36 | | -s | Saves a table to a file. | | ||
| 37 | 3 | Per Amundsen | | -f | Free/delete a table. | | 
| 38 | | -T | Indicates the type is text. | | ||
| 39 | | -N | Indicates the type is a number. | | ||
| 40 | | -B | Indicates the type is a boolean. | | ||
| 41 | | -A | Indicates the type is a sub table/array. | | ||
| 42 | 6 | Per Amundsen | | -J | Indicates the file to load/save should be in "JSON":https://en.wikipedia.org/wiki/JSON format. | | 
| 43 | | -X | Indicates the file to load/save should be in "XML":https://en.wikipedia.org/wiki/XML format. | | ||
| 44 | | -I | Indicates the file to load/save should be in "INI":https://en.wikipedia.org/wiki/INI_file format. | | ||
| 45 | 1 | Per Amundsen | |
| 46 | *Example* | ||
| 47 | |||
| 48 | <pre> | ||
| 49 | ; Add item1/value1 to the table 'table1'. | ||
| 50 | //mtable -a table1 item1 value1 | ||
| 51 | |||
| 52 | ; Add sub table 'item2' to the table 'table1'. | ||
| 53 | //mtable -aA table1 item2 value2 | ||
| 54 | |||
| 55 | ; Insert item3/value3 at position '1' in the table 'table1'. | ||
| 56 | //mtable -i table1 1 item3 value3 | ||
| 57 | |||
| 58 | ; Print number of items in table 'table1'. | ||
| 59 | //echo -ag Number of items in table1 is $mtable(table1, 0) | ||
| 60 | |||
| 61 | ; Print the first items in table 'table1'. | ||
| 62 | //echo -ag First item in table1 is $mtable(table1, 1).item | ||
| 63 | |||
| 64 | ; Delete the first item in table 'table1'. | ||
| 65 | //mtable -d table1 1 | ||
| 66 | |||
| 67 | ; Free the table 'table1'. | ||
| 68 | //mtable -f table1 | ||
| 69 | |||
| 70 | ; Add a new sub table to table 'table1', | ||
| 71 | //mtable -aA table1 sub1 sub1 | ||
| 72 | |||
| 73 | ; Add a new item to the sub table located at position '1' in table 'table1'. | ||
| 74 | //mtable -a table1 1 item1 value1 | ||
| 75 | |||
| 76 | ; Print the first item in the table 'table1', which is a sub table. | ||
| 77 | //echo -ag First item in table1 is $mtable(table1, 1).item - $mtable(table1, 1).type | ||
| 78 | |||
| 79 | ; Print the first item in the sub table located at position '1' in table 'table1'. | ||
| 80 | //echo -ag First item in sub table1 is $mtable(table1, 1, 1).item | ||
| 81 | |||
| 82 | ; Generates a json output of table 'table1'. | ||
| 83 | // echo -ag $mtable(table1).json | ||
| 84 | |||
| 85 | ; Generates a ini output of table 'table1'. | ||
| 86 | // echo -ag $mtable(table1).ini | ||
| 87 | |||
| 88 | ; Generates a xml output of sub table at position '1' in table 'table1'. | ||
| 89 | // echo -ag $mtable(table1, 1).xml | ||
| 90 | </pre> |