Click or drag to resize

AIns Function (Array, DWord)

X#
Insert an element into an array and assign it a NIL value.

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

Parameters

aTarget
Type: Array
The array into which the element will be inserted.
dwPosition
Type: DWord
The position at which the element will be inserted.

Return Value

Type: Array
A reference to aTarget.
Remarks
AIns() inserts a new element into a specified array.
The newly inserted element is NIL until a new value is assigned to it.
After the insertion, the last element in the array is discarded, and all elements after the new element are shifted down one position. AIns() must be used carefully with multidimensional arrays.
Using AIns() in a multidimensional array discards the last element in the specified target array which, if it is an array element, will cause one or more dimensions to be lost.
To insert a new dimension into an array, first add a new element to the end of the array using AAdd() or ASize() before using AIns().
Examples
This example demonstrates the effect of using AIns() on an array:
X#
1LOCAL aArray AS ARRAY
2aArray := {1, 2, 3}            // aArray is now {1, 2, 3}
3AIns(aArray, 2)            // aArray is now {1, NIL, 2}
See Also