Difference between revisions of "ObjectType:array"
Jump to navigation
Jump to search
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{ObjectType-Vitals|array|[[LavishScript]]|[[ObjectType:objectcontainer|objectcontainer]]|NULL|none|yes|CDataArray *}} | ||
== Description == | == Description == | ||
− | |||
An array is a statically-sized (predefined size) list of objects. All objects in the array are created and destroyed with the array object itself -- they cannot be destroyed or created otherwise. | An array is a statically-sized (predefined size) list of objects. All objects in the array are created and destroyed with the array object itself -- they cannot be destroyed or created otherwise. | ||
Line 6: | Line 6: | ||
See the [[ObjectType:index|index object type]] for a dynamically-sized list type in which the contained objects are not created with the object itself, and can be created or destroyed later. An Index cannot have multiple dimensions, but you can create an array of indexes. | See the [[ObjectType:index|index object type]] for a dynamically-sized list type in which the contained objects are not created with the object itself, and can be created or destroyed later. An Index cannot have multiple dimensions, but you can create an array of indexes. | ||
− | Arrays are 1-based. | + | '''Arrays are 1-based.''' |
+ | |||
== Members == | == Members == | ||
− | *[[ | + | *[[ObjectType:uint|uint]] '''Dimensions''': Total number of extents of the array (e.g. 2-dimensional has two extents) |
− | *[[ | + | *[[ObjectType:uint|uint]] '''Size''': Total number of elements in the array, including all dimensions |
− | *[[ | + | *[[ObjectType:uint|uint]] '''Size['''#''']''': Total number of elements in a given dimension of the array |
*[[ObjectType:mutablestring|mutablestring]] '''Expand['''begin #''','''length''']''': Retrieves the text representation of each object in the array as quoted parameters, separated by spaces. If no parameters are given to Expand, the entire array will be used. If only the begin # is used, the rest of the array, beginning with the element # specified, will be used. If the length is additionally given, that number of elements from the array will be used, beginning with the element # specified as the beginning. | *[[ObjectType:mutablestring|mutablestring]] '''Expand['''begin #''','''length''']''': Retrieves the text representation of each object in the array as quoted parameters, separated by spaces. If no parameters are given to Expand, the entire array will be used. If only the begin # is used, the rest of the array, beginning with the element # specified, will be used. If the length is additionally given, that number of elements from the array will be used, beginning with the element # specified as the beginning. | ||
*[[ObjectType:mutablestring|mutablestring]] '''ExpandComma['''begin #''','''length''']''': Retrieves the text representation of each object in the array as quoted parameters, separated by commas. If no parameters are given to Expand, the entire array will be used. If only the begin # is used, the rest of the array, beginning with the element # specified, will be used. If the length is additionally given, that number of elements from the array will be used, beginning with the element # specified as the beginning. | *[[ObjectType:mutablestring|mutablestring]] '''ExpandComma['''begin #''','''length''']''': Retrieves the text representation of each object in the array as quoted parameters, separated by commas. If no parameters are given to Expand, the entire array will be used. If only the begin # is used, the rest of the array, beginning with the element # specified, will be used. If the length is additionally given, that number of elements from the array will be used, beginning with the element # specified as the beginning. | ||
+ | *[[ObjectType:unistring|unistring]] '''AsJSON''': Returns a JSON array representation of this array, with each element converted by using its AsJSON member | ||
+ | |||
== Methods == | == Methods == | ||
− | + | * '''ForEach['''code''']''': For each element in the array, performs the specified code. The [[TLO:ForEach|ForEach Top-Level Object]] is used to access the Key or Value for each iteration | |
+ | |||
== Examples == | == Examples == | ||
Line 36: | Line 40: | ||
;Output | ;Output | ||
149.23 | 149.23 | ||
− | |||
== See Also == | == See Also == | ||
− | + | {{LavishScript:ObjectType}} | |
− | |||
− | |||
− |
Latest revision as of 14:40, 14 October 2019
array | |
Defined By | LavishScript |
Inherits | objectcontainer |
Reduces To | NULL |
Variable Object Type | none |
Uses Sub-Types | yes |
C/C++ Type | CDataArray * |
Contents
Description
An array is a statically-sized (predefined size) list of objects. All objects in the array are created and destroyed with the array object itself -- they cannot be destroyed or created otherwise.
See the index object type for a dynamically-sized list type in which the contained objects are not created with the object itself, and can be created or destroyed later. An Index cannot have multiple dimensions, but you can create an array of indexes.
Arrays are 1-based.
Members
- uint Dimensions: Total number of extents of the array (e.g. 2-dimensional has two extents)
- uint Size: Total number of elements in the array, including all dimensions
- uint Size[#]: Total number of elements in a given dimension of the array
- mutablestring Expand[begin #,length]: Retrieves the text representation of each object in the array as quoted parameters, separated by spaces. If no parameters are given to Expand, the entire array will be used. If only the begin # is used, the rest of the array, beginning with the element # specified, will be used. If the length is additionally given, that number of elements from the array will be used, beginning with the element # specified as the beginning.
- mutablestring ExpandComma[begin #,length]: Retrieves the text representation of each object in the array as quoted parameters, separated by commas. If no parameters are given to Expand, the entire array will be used. If only the begin # is used, the rest of the array, beginning with the element # specified, will be used. If the length is additionally given, that number of elements from the array will be used, beginning with the element # specified as the beginning.
- unistring AsJSON: Returns a JSON array representation of this array, with each element converted by using its AsJSON member
Methods
- ForEach[code]: For each element in the array, performs the specified code. The ForEach Top-Level Object is used to access the Key or Value for each iteration
Examples
Declare an array of strings
- declare Array1[20] string
Declare a 3 dimensional array of floats
- declare Array2[20,15,5] float global
Display total dimensions of an array
- echo Dimensions: ${Array2.Dimensions}
- Output
Dimensions: 3
Display number of elements in a specific dimension
- echo Elements in dimension 2: ${Array2.Size[2]}
- Output
Elements in dimension 2: 15
Set and display the element at [2,3,1]
- Array2[2,3,1]:Set[149.23]
- echo ${Array2[2,3,1]}
- Output
149.23
See Also
LavishScript Object Types
- Text
- string - mutablestring - unistring
- Numbers
- byte - float - float64 - int - uint - int64
- Boolean (TRUE/FALSE)
- bool
- Pointers
- boolptr - byteptr - floatptr - float64ptr - intptr - uintptr - int64ptr - rgbptr - stringptr
- Containers
- objectcontainer - array - index - collection - queue - stack - set - variablescope
- JSON
- jsonobject - jsonarray - jsonvaluecontainer - jsonvalue
- Iteration
- iterator - jsoniterator
- Date/Time
- time
- File Handling
- filepath - file - filelist - filelistentry
- Tasks
- lavishmachine - Accessed via the Top-Level Object LMAC
- task - tasklibrary - taskmanager - tasktype - taskpulseargs - elmactaskstate