ASCAN()

From Lianjapedia
Revision as of 11:19, 30 January 2017 by Yvonne.milne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

Function to search an array for an expression

Syntax

ASCAN(<array>, <exp> [, <nStart> [, <nElements> [, <nColumn> [, <nFlags>]]]])

See Also

AADD(), AAVERAGE(), ACOPY(), ADEL(), ADESC(), ADIR(), AELEMENT(), AFIELDS(), AFILL(), AINS(), ALEN(), AMAX(), AMIN(), APPEND FROM ARRAY, ARRAY(), ASIZE(), ASORT(), ASTORE(), ASTRING(), ASUBSCRIPT(), ASUM(), COPY TO ARRAY, DECLARE, DIMENSION, GATHER, IN_ARRAY(), IS_ARRAY(), LOCAL, PRIVATE, PUBLIC, RELEASE, RESTORE, SAVE, SCATTER, SET EXACT

Description

The ASCAN() function searches an array for the expression specified in <exp>. The expression may consist of any data type. It returns the element number at which the expression is located, or 0 if not found. The element number returned is the first occurrence of the string found.

Parameters Required Description
<array> Yes The array to search.
<exp> Yes The expression to search for.
<nStart> No The element number to start searching from. For two dimensional arrays, use the element number, not the subscripts (AELEMENT()). If not specified then the search starts at the first element.
<nElements> No The number of elements to search. For two dimensional arrays, use the element number, not the subscripts (AELEMENT()). If not specified then the search continues to the last element.
<nColumn> No The array column to search in a two-dimensional array. If <nColumn> is specified and is greater than 0, then the array is treated as a one-dimensional array, so <nStart> and <nElements> should be specified accordingly.
<nFlags> No Additional search criteria, see below.

Flags

<nFlags> Description
1 Case Insensitive
3 Case Insensitive
4 Exact off
5 Case Insensitive, Exact off
6 Exact on
7 Case Insensitive, Exact on
8 Return row number
9 Case Insensitive, Return row number
10 Return row number
11 Case Insensitive, Return row number
12 Return row number, Exact off
13 Case Insensitive, Return row number, Exact off
14 Return row number, Exact on
15 Case Insensitive, Return row number, Exact on

Example

close data
open database southwind
 
use employees
copy to array names
 
eExpression = "Rob"
nStartElement = 5
nElementsSearched = 104
nSearchColumn = 0
 
element_no=ascan(names, eExpression, nStartElement, nElementsSearched)
if element_no > 0
    ? names[element_no]
    ? element_no
else
	? "Not found"
endif
 
// Exact on
element_no=ascan(names, eExpression, nStartElement, nElementsSearched, nSearchColumn, 6)
if element_no > 0
    ? names[element_no]
    ? element_no
else
	? "Not found"
endif
 
nStartRow = 3
nRowsSearched = 6
nSearchColumn = 3
 
element_no=ascan(names, eExpression, nStartRow, nRowsSearched, nSearchColumn)
if element_no > 0
    ? names[element_no]
    ? element_no
else
	? "Not found"
endif
 
// Return row number, exact off
row_no=ascan(names, eExpression, nStartRow, nRowsSearched, nSearchColumn, 10)
if row_no > 0
    ? names[row_no, nSearchColumn]
    ? row_no
else
	? "Not found"
endif
 
// Return row number, exact on
row_no=ascan(names, eExpression, nStartRow, nRowsSearched, nSearchColumn, 14)
if row_no > 0
    ? names[row_no, nSearchColumn]
    ? row_no
else
	? "Not found"
endif