Click or drag to resize

AIns Function (FoxArray, DWord, DWord)

X#
Inserts an element into a one-dimensional array, or a row or column into a two-dimensional array.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION AIns(
	ArrayName AS FOXARRAY,
	nElementNumber AS DWORD,
	 nInsertType AS DWORD
) AS DWORD
Request Example View Source

Parameters

ArrayName
Type: FoxArray
Specifies the name of the array into which the element is inserted.
nElementNumber
Type: DWord
Specifies where the new element, row, or column is inserted into the array. To insert an element into a one-dimensional array, include ArrayName and the element nElementNumber where the insertion occurs. The new element is inserted just before element nElementNumber. To insert a row into a two-dimensional array, include ArrayName and the number of the row nElementNumber where the insertion occurs. The new row is inserted just before row nElementNumber. For more information on referencing an array element by its subscripts, see DIMENSION Command. 2 Inserts a column into a two-dimensional array. The new column is inserted just before the column specified with nElementNumber.
nInsertType
Type: DWord

Return Value

Type: DWord
Numeric
Remarks
Inserting an element, row, or column into an array does not change the size of the array. The trailing elements, rows, or columns are shifted toward the end of the array and the last element, row, or column in the array is dropped from it. The newly inserted element, row, or column is initialized to false (.F.). AINS( ) returns 1 if the element, row, or column is successfully inserted.
Examples
X#
 1CLOSE DATABASES
 2OPEN DATABASE (HOME(2) + 'Data\testdata')
 3USE customer     // Open customer table
 4SELECT company FROM customer ;
 5WHERE country = 'Germany' ;
 6INTO ARRAY gaCompanies
 7gnCount = _TALLY
 8gcName = 'Seven Seas Imports'
 9CLEAR
10DISPLAY MEMORY LIKE gaCompanies
11IF ASCAN(gaCompanies, gcName) = 0  // Search for company
12*** Company not found-add it ***
13DIMENSION gaCompanies[gnCount+1,1]
14= AINS(gaCompanies, gnCount-1)
15gaCompanies[gnCount-1] = gcName
16ENDIF
17DISPLAY MEMORY LIKE gaCompanies
See Also