Click or drag to resize

Hb_AIns Function

X#
Inserts a value at an array subscript position and optionally increases the length of array.

Namespace:  XSharp.Harbour
Assembly:  XSharp.Harbour (in XSharp.Harbour.dll) Version: 2.21
Syntax
 FUNCTION Hb_AIns(
	aArray,
	nPos,
	xValue,
	lAutoSize
) AS ARRAY CLIPPER
Request Example View Source

Parameters

aArray (Optional)
Type: Usual
Name of array from which an element is to be removed.
nPos (Optional)
Type: Usual
Subscript of the element to be removed. Default value: 1.
xValue (Optional)
Type: Usual
Value to be inserted
lAutoSize (Optional)
Type: Usual
Boolean flag specifying if the array will be resized or not. Default value: .F. (no resize).

Return Value

Type: Array
The changed array
Remarks
This function inserts xValue in the nPos position of the array, moving all the items one position down in the array list.
If lAutoSize is .T., a new element will be added at the end of array, making room for the previous last element, which means the length of array will be increased by 1.
If lAutoSize is .F. (or is not passed) the function behaves like AIns(), that is, the size of aArray won't change and the last item of aArray will be lost.
Examples
X#
1LOCAL aArray := {1,3,4}
2hb_AIns( aArray, 2 ,2)
3? Alen(aArray)  // 3
4? aTail(aArray) // 3
5aArray := {1,3,4}
6hb_AIns( aArray, 2 , 2, .T.)
7? Alen(aArray) // 4
8? ATail(aArray) // 4
See Also