AIns Function (Array, DWord, DWord) | |
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 ARRAY,
nElementNumber AS DWORD,
nInsertType AS DWORD
) AS DWORD
public static uint AIns(
Array ArrayName,
uint nElementNumber,
uint nInsertType
)
Request Example
View SourceParameters
- ArrayName
- Type: Array
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.
Remarks The parameter to this function is a 'General Array'. The function decides at runtime if the array is a FoxPro array or a 'General' Array
Examples 1CLOSE DATABASES
2OPEN DATABASE (HOME(2) + 'Data\testdata')
3USE customer
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
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