Project

General

Profile

Testasd » History » Revision 58

Revision 57 (Per Amundsen, 02/07/2023 03:01 PM) → Revision 58/73 (Per Amundsen, 02/07/2023 03:02 PM)

h1. Multidimensional arrays 

 */marray -a <name> [N..] <type> <item> <value>* 

 add item 

 */marray -e <name> [N..] <N> <type> <item> <value>* 

 edit item 

 */marray -i <name> [N..] <N> <type> <item> <value>* 

 insert item 

 */marray -d <name> [N..] <N>* 

 delete item 

 */marray -f <name>* 

 delete/free table 

 *$marray(name, N, [N..])* 

 gets the Nth item in a table, subsequent N parameters gets the Nth item from a sub table, infinite sub depth. 

 *Switches* 

 .item - Get item. 
 .value - Get item value. 
 .type - Get item type. (0 = text, 1 = number, 2 = bool, 3 = bvar, 4 = sub table) 
 .json - TODO, generate a json table from all items in the table and all sub tables' 
 .ini - ? 

 *Examples* 

 <pre> 
 ; Add item1/value1 to the table 'table1'. 
 //marray -a table1 0 item1 value1 

 ; Add item2/value2 to the table 'table1'. 
 //marray -a table1 4 item2 value2 

 ; Insert item3/value3 at position '1' in the table 'table1'. 
 //marray -i table1 1 0 4 item3 value3 

 ; Print number of items in table 'table1'. 
 //echo -ag Number of items in table1 is $marray(table1, 0) 

 ; Print the first items in table 'table1'. 
 //echo -ag First item in table1 is $marray(table1, 1).item 

 ; Delete the first item in table 'table1'. 
 //marray -d table1 1 

 ; Free the table 'table1'. 
 //marray -f table1 

 ; Add a new sub table to table 'table1', 
 //marray -a table1 4 sub1 sub1 

 ; Add a new item to the sub table located at position '1' in table 'table1'. 
 //marray -a table1 1 0 item1 value1 

 ; Print the first item in the table 'table1', which is a sub table. 
 //echo -ag First item in table1 is $marray(table1, 1).item - $marray(table1, 1).type 

 ; Print the first item in the sub table located at position '1' in table 'table1'. 
 //echo -ag First item in sub table1 is $marray(table1, 1, 1).item 
 </pre>