ARRAYATTR function

Purpose | Return descriptive attributes of a given array.
Syntax | y = ARRAYATTR(Arr(), AttrNum)

Remarks

ARRAYATTR returns various descriptive attributes of an array, depending upon the value of AttrNum

AttrNum | Definition
0 | Returns TRUE (-1) if the array is currently dimensioned, FALSE (0) if not.
1 | Returns the data type, as defined in the following table. Note that the numeric equates listed on the right of the table are built into PowerBASIC, but the numeric values they represent are subject to change. Therefore, application code should always use the numeric equates rather than the numeric value, to ensure compatibility with future versions of PowerBASIC. The current data type definitions are:
| Type | Array type | Keyword | Equate
| 0 | Byte | BYTE | %VARCLASS_BYT
| 1 | Word | WORD | %VARCLASS_WRD
| 2 | Double-word | DWORD | %VARCLASS_DWD
| 4 | Integer | INTEGER | %VARCLASS_INT
| 5 | Long-integer | LONG | %VARCLASS_LNG
| 8 | Quad-integer | QUAD | %VARCLASS_QUD
| 10 | Single-precision | SINGLE | %VARCLASS_SNG
| 11 | Double-precision | DOUBLE | %VARCLASS_DBL
| 12 | Extended-precision | EXT | %VARCLASS_EXT
| 13 | Currency | CURRENCY | %VARCLASS_CUR
| 14 | Extended Currency | CURRENCYX | %VARCLASS_CUX
| 17 | Variant | VARIANT | %VARCLASS_VRNT
| 18 | Interface | INTERFACE | %VARCLASS_IFAC
| 19 | GUID | GUID | %VARCLASS_GUID
| 20 | UDT or Union | TYPE/UNION | %VARCLASS_TYPE
| 21 | ANSI NulTrm string | ASCIIZ/STRINGZ * n | %VARCLASS_STRZ
| 22 | Fixed-length string | STRING * n | %VARCLASS_FIX
| 23 | Dynamic string | STRING | %VARCLASS_STR
| 24 | Field string | FIELD | %VARCLASS_FLD
| 25 | Wide NulTrm string | WSTRINGZ | %VARCLASS_WSTRZ
| 26 | Wide FixLen string | WSTRING * n | %VARCLASS_WFIX
| 27 | Wide Dynamic string | WSTRING * n | %VARCLASS_FLD
| 28 | Wide Field string | WFIELD | %VARCLASS_WFLD
| 2 | Returns TRUE (-1) if it is an array of pointers, FALSE (0) if not.
| 3 | Returns the number of dimensions of the array. The lower and upper boundaries of each dimension can be retrieved with the LBOUND and UBOUND functions respectively
| 4 | Returns the total number of elements in the array. For example, the array DIM A&(3,4,5) would comprise 120 elements (4 x 5 x 6 = 120).
| 5 | Returns the array element size. For example, an array of Double-precision variables would be 8 bytes. For dynamic strings, the size of the string handle (4 bytes) is returned. For DISPATCH and INTERFACE arrays, ARRAYATTR returns the size of a pointer variable (4 bytes).

See also | DIM, LBOUND, UBOUND, PowerArray, REDIM

Example

DIM z(3,4,5) AS CURRENCYX

DIM x AS LONG, Answer AS STRING

FOR x = 0 TO 5

Answer = Answer + FORMAT$(x)

Answer = Answer + $TAB

Answer = Answer + FORMAT$(ARRAYATTR(z(),x))

Answer = Answer + $CRLF

NEXT x

' The results are stored in Answer:

Result

0 -1

1 14

2 0

3 3

4 120

5 8