<< Click to Display Table of Contents >> Navigation: 3. Script Language > Variable Definitions and Operations > Array -Commands |
Array Commands
Using the new 1 - dimensional Arrays you can more easily Script tasks.
This chapter provides a comprehensive guide on 1-dimensional arrays in scripting, focusing on three types:
•String-Array
•Integer (INT)
•Floating-Point (FP) arrays.
1. String/Text-Arrays
ARR.Set|Array-Name|Array Index|Value
Example:
ARR.Set|1|0|Hello
ARR.Get|Array-Name|Array Index|Variable
Example:
ARR.Get|1|0|$$RET
2. Integer Arrays (INT)
ARR.Set INT Array|Array-Name|Array Index|Value
Value: A signed integer within a 64-bit range.
Example:
ARR.Set INT Array|1|0|42
ARR.Get INT Array|Array-Name|Array Index|Variable
Example:
ARR.Get INT Array|1|0|myIntVar
3. Floating-Point Arrays (FP)
ARR.Set FP Array|Array-Name|Array Index|Value
Value: Extended-precision variable, 10 bytes of storage, 18 digits of precision.
Example:
ARR.Set FP Array|1|0|3.14159
ARR.Get FP Array|Array-Name|Array Index|Variable
Example:
ARR.Get FP Array|1|0|myFPVar
Inside the code, all Datatypes are stored "as String". Means, technically also the INT-Arrays and the FP-Arrays are String-Arrays.
Therefore you can use
' Fill Element 0 of Array Nr.1 with the INT-Value of "42" which is stored as an 8-Byte String (64-Bit)
' Set Array with an 64-bit signed Integer Value
ARR.Set INT Array|1|0|42
' Return Array Content as String
ARR.Get|1|0|$$RET
' This will return an Binary value that defines the 64-bit Signed-Integer value for "42"
MBX.$$RET
Therefore, if you know what you are doing, you can theoretically fill all even Array-Elements with INT Values,
and put in all odd Array-Values Strings (what ever). You can mix the Datatypes as long as you know what is in where.
You can also use another Array to index what Datatype is in which Array-Element and this way construct a mix of Elements.
Technically the 32-Bit Memory is the only Limitation for the number of Array-Elements.
The same applies for the length of a Single String-Element.