Click or drag to resize

Functions.ArraySwap Method (__Array, UInt32, __Usual)

Replace an array element with a new value and return the old value.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.2
Syntax
 FUNCTION ArraySwap(
	aTarget AS ARRAY,
	dwElement AS DWORD,
	uNewValue AS USUAL
) AS USUAL
View Source

Parameters

aTarget
Type: __Array
The array whose element will be replaced with a new value.
dwElement
Type: UInt32
The number of the element to be replaced.
uNewValue
Type: __Usual
The new value.

Return Value

Type: __Usual
The value that was replaced by <uNewValue>.
Remarks
ArraySwap() replaces the element specified with a new value.
Examples
This example swaps the second and third elements of an array:
X#
FUNCTION Start()
        LOCAL aList[4]
        ArrayPut(aList, 1, "First")
        ArrayPut(aList, 2, "Second")
        ArrayPut(aList, 3, "Third")
        ArrayPut(aList, 4, "Fourth")
        aList[3] := ArraySwap(aList, 2, aList[3])
See Also