Click or drag to resize

ArrayGetT Function (Array OfT, DWord)

X#
Read an array element.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION ArrayGet<T>(
	aTarget AS ARRAY OF<T>,
	dwElement AS DWORD
)
 AS T
Request Example View Source

Parameters

aTarget
Type: Array OfT
The array to read.
dwElement
Type: DWord
The number of the element to read.

Type Parameters

T
The type of the array elements

Return Value

Type: T
The value held by the element.
Remarks
ArrayGet() reads and returns an array element's value.
Examples
This example creates an array and prints the values:
X#
 1FUNCTION Start()
 2    LOCAL aStates[3]
 3    LOCAL i AS SHORTINT
 4    ArrayPut(aStates, 1, "Montana")
 5    ArrayPut(aStates, 2, "Wyoming")
 6    ArrayPut(aStates, 3, "Idaho")
 7    FOR i := 1 UPTO ALen(aStates)
 8        QOut(ArrayGet(aStates, i))
 9    NEXT
10    // Below we print the same array in two different
11    // ways from the above:
12    // Functional equivalent of FOR...NEXT
13    AEval(aStates, {|Element| QOut(Element)})
14    // Using [] to get an array element
15    FOR i := 1 UPTO ALen(aStates)
16        QOut(aStates[i])
17    NEXT
See Also