Click or drag to resize

AInsT Function (Array OfT, UInt32)

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

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.4a
Syntax
 FUNCTION AIns<T>(
	aTarget AS ARRAY OF<T>,
	dwPosition AS DWORD
)
WHERE T : NEW()
 AS ARRAY OF<T>
View Source

Parameters

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

Type Parameters

T
The type of the array elements

Return Value

Type: Array OfT
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