Click or drag to resize

ArraySwap Function (Array, DWord, Usual)

X#
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.19
Syntax
 FUNCTION ArraySwap(
	aTarget AS ARRAY,
	dwElement AS DWORD,
	uNewValue AS USUAL
) AS USUAL
Request Example View Source

Parameters

aTarget
Type: Array
The array whose element will be replaced with a new value.
dwElement
Type: DWord
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#
1FUNCTION Start()
2    LOCAL aList[4]
3    ArrayPut(aList, 1, "First")
4    ArrayPut(aList, 2, "Second")
5    ArrayPut(aList, 3, "Third")
6    ArrayPut(aList, 4, "Fourth")
7    aList[3] := ArraySwap(aList, 2, aList[3])
See Also