Difference between revisions of "ASCAN()"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
(Description)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to search an array for an expression
 
Function to search an array for an expression
 
  
 
==Syntax==
 
==Syntax==
ASCAN(<array>, <exp>, [<expN>])
+
ASCAN(<array>, <exp> [, <nStart> [, <nElements> [, <nColumn> [, <nFlags>]]]])
 
+
  
 
==See Also==
 
==See Also==
[[AADD()]], [[AAVERAGE()]], [[ABROWSE()]], [[ACHOICE()]], [[ACOL()]], [[ACOPY()]], [[ADEL()]], [[ADESC()]], [[ADIR()]], [[AELEMENT()]], [[AFIELDS()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[AROW()]], [[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]]
+
[[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==
 
==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.  The SET EXACT command does not alter the find condition because the ASCAN() function works as if SET EXACT were OFF.  The optional expression <expN> specifies the position at which to start the scan.  If the <expN> is not specified then the search starts at the first element.
+
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.
  
 +
{|class="wikitable" width="100%"
 +
!width="20%"|Parameters||Required||Description
 +
|-
 +
|valign="top"|<array>||valign="top"|Yes||The array to search.
 +
|-
 +
|valign="top"|<exp>||valign="top"|Yes||The expression to search for.
 +
|-
 +
|valign="top"|<nStart>||valign="top"|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.
 +
|-
 +
|valign="top"|<nElements>||valign="top"|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.
 +
|-
 +
|valign="top"|<nColumn>||valign="top"|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.
 +
|-
 +
|valign="top"|<nFlags>||valign="top"|No||Additional search criteria, see below.
 +
|-
 +
|}
 +
 +
===Flags===
 +
 +
{|class="wikitable" width="100%"
 +
!width="20%"|<nFlags>||Description
 +
|-
 +
|valign="top"|1||valign="top"|Case Insensitive
 +
|-
 +
|valign="top"|3||valign="top"|Case Insensitive
 +
|-
 +
|valign="top"|4||valign="top"|Exact off
 +
|-
 +
|valign="top"|5||valign="top"|Case Insensitive, Exact off
 +
|-
 +
|valign="top"|6||valign="top"|Exact on
 +
|-
 +
|valign="top"|7||valign="top"|Case Insensitive, Exact on
 +
|-
 +
|valign="top"|8||valign="top"|Return row number
 +
|-
 +
|valign="top"|9||valign="top"|Case Insensitive, Return row number
 +
|-
 +
|valign="top"|10||valign="top"|Return row number
 +
|-
 +
|valign="top"|11||valign="top"|Case Insensitive, Return row number
 +
|-
 +
|valign="top"|12||valign="top"|Return row number, Exact off
 +
|-
 +
|valign="top"|13||valign="top"|Case Insensitive, Return row number, Exact off
 +
|-
 +
|valign="top"|14||valign="top"|Return row number, Exact on
 +
|-
 +
|valign="top"|15||valign="top"|Case Insensitive, Return row number, Exact on
 +
|-
 +
|}
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
use accounts
+
close data
declare names[reccount(),1]
+
open database southwind
copy to array names fields company
+
 
element_no=ascan(names, "OK Cleaning Company")
+
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
 
if element_no > 0
     ? names[m->element_no]
+
     ? names[element_no]
     OK Cleaning Company
+
     ? element_no
 
else
 
else
    dialog box "The company was not found."
+
? "Not found"
 
endif
 
endif
</code>
 
  
 +
// 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
 +
</code>
  
==Products==
 
Recital, Recital Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Array Processing]]
 
 
[[Category:Array Processing Functions]]
 
[[Category:Array Processing Functions]]

Latest revision as of 12:19, 30 January 2017

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