ASCAN( ) Function
Searches an array for an element containing the same data and data type as an expression.
ASCAN(ArrayName, eExpression [, nStartElement [, nElementsSearched [, nSearchColumn [, nFlags ]]]]) |
Parameters
- ArrayName
-
Specifies the name of the array to search.
- eExpression
-
Specifies the general expression to search for.
- nStartElement
-
Specifies the element number at which the search begins. The element number you specify is included in the search. If you omit nStartElement or if you pass negative value on its place, the entire array is searched by default.
- nElementsSearched
-
Specifies the number of elements that are searched. If you omit nStartElement and nElementsSearched or if you pass negative value on its place, the search begins with the first array element and continues to the last array element if you do not specify nSearchColumn.
Note You can refer to an element in a two-dimensional variable array in one of two ways. The first method uses two subscripts to specify the row and column position of the element in the array; the other method uses an element number. This function and others that manipulate two-dimensional arrays require element numbers (nStartElement and nElementsSearched). Use AELEMENT( ) to return the element number from row and column subscripts in a two-dimensional array.
- nSearchColumn
-
Specifies the array column to search. This is often useful in arrays created by functions such as AFIELDS( ).
You can use 0 or a negative number for nSearchColumn to impose a search of the entire array. If you use a value greater than 0 for nSearchColumn, ASCAN( ) treats the specified column as a one-dimensional array, using each data row as an element in the search. For instance, the following example searches only the third and fourth elements of column 2 instead of the entire array.
Copy Code? ASCAN(abc,"M",3,2,2)
Visual FoxPro generates an error if nSearchColumn is a number larger than the number of available columns.
TipsIf the nSearchColumn parameter is used then nStartElement and nElementsSearched parameters cannot be omitted. Use –1 as the replacement value.
? ASCAN(abc,"HELLO",-1,-1,2,15) && Search the whole column 2 of two-dimensional array
- nFlags
-
Specifies additional search criteria to apply to the scan function. Default scans are case-sensitive.
The number you specify in nFlags provides a bit-value that determines the case sensitivity or exactness setting of a scan according to the following table:
NFlag Bit Description 0
0000
Behavior existing in Visual FoxPro 6 or earlier
1
0001
Case Insensitive
2
0010
Current behavior existing in the previous version of Visual FoxPro
3
0011
Case Insensitive
4
0100
Exact OFF
5
0101
Case Insensitive; Exact OFF
6
0110
Exact ON
7
0111
Case Insensitive; Exact ON
8
1000
Return row number
9
1001
Case Insensitive; return row number
10
1010
Return row number
11
1011
Case Insensitive; return row number
12
1100
Return row number; Exact OFF
13
1101
Case Insensitive; Return row number; Exact OFF
14
1110
Return row number; Exact ON
15
1111
Case Insensitive; Return row number; Exact ON
The bit values are as follows:
| Bit | Description |
|---|---|
|
0 |
Case Insensitive bit |
|
1 |
Exactness ON bit (Only effective if bit 2 is set) |
|
2 |
Override system Exact setting bit |
|
3 |
Return row number if 2D array |
nFlags applies only to the ASCAN( ) function and does not affect settings for SET EXACT.
Return Value
Remarks
Example
See Also
© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic
Microsoft Visual FoxPro 9 SP2 Help file, VFPX Edition v1.08