list (replaces TList)
The list function lists the contents of a general lua table. Every table element is listed in the format [key]=value. If named key is not present, an integral subscript is assigned. Nested, or multi-dimensional tables are supported.
list( value )
value is lua table.
This function lists all table elements with {} around the values in each sub-table. As a consequence of the way lua stores table entries, both non-keyed values and keyed values specified with a numeric (integer) key are retrieved in index order. Keyed values are returned in an unspecified order.
Nested tables are each indented at the nesting level with enclosing {} to denote the table extent. See the example below.
The list function automatically prints a new line ('\n') at the beginning of the list.
The following script creates a complex multi-dimensional table and lists its contents. Notice that the printed list heading does not end with a newline ('\n') character because list() automatically prefixes the listing with a newline.
|
-- create a table |
|
-- print a heading |
|
-- list the table |
This script produces the output shown below. Notice that non-keyed array components are always listed first, in index order, within their respective table. The non-keyed ("array") elements such as 5 and "My Name" are listed first because they assume integral indices. The keyed (non-array) elements A=1 and r=3 are listed after the indexed elements in arbitrary order within their respective tables.
In the next example, the table contains no explicit key names and is considered to be a pure "array". Hence all elements assume integral indices in the order specified. The list is therefore in index order.
|
-- create a table |
|
-- create a table |
|
-- list the table |
The list is shown below, Note the nested table W at array index 3:
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.