Click or drag to resize

ArrayGet Function (Array, DWord)

X#
Read an array element.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION ArrayGet(
	aTarget AS ARRAY,
	dwElement AS DWORD
) AS USUAL
Request Example View Source

Parameters

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

Return Value

Type: Usual
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