FIND

Contents


"find" is used to find a particular value from a series of numerical, alphanumerical or date expressions or variables .

 

Syntax

   find( value_to_seek, list_exprg )

 

Parameters

Element

Description

Comments

value_to_seek 

Expression to be searched for from the following list of arguments.

None.

list_exprg 

List of expressions_généralisées separated by ','.

All expressions must be the same type.

 

Examples

   # Simple search: X is a table of values declared as X(1…N)
    I = find(VALEUR, X)
    Infbox VALEUR-"is at position"-I-" in table X"
   # After an initial entry in the table, return to
   # the first column for a value required
    FNC_RECHERCHE
       Integer I
       I = find(VALEUR_RECH,[M]COLONNE1(0..[M]NBL-1))
       If I<>0
          zonsui = sum("COLONNE1(", num$(I-1), ")")
       Endif
   # If I is null, the search has been unsuccessful
    Return
   # Search for values in a string table
    Char LIGNES(5)(40)     :# 40 strings of 5 characters maximum
    Gosub LIRE_LIGNES      :# Fills the LIGNES table
    I = pat(sum(LIGNES(0..39)), "*A*")
    If I <> 0
       Infbox "There is an 'A' in at least one of the lines"
    Endif
    I = find("A", LIGNES(0..39))
    If I <> 0
       Infbox 'There is at least one of the lines equal to "A" '
    Endif

 

Description et commentaires

"find" is used to find a particular value from a series of numerical, alphanumerical or date expressions or variables. "find" returns the position of the value found in the list given, if the value is found (from 1 to the number of values in the list) or 0 if the value was not found.

For a search through a series of numerical values, Integer, Shortint, Decimal and Text type expressions and variables may be mixed.

If one of the arguments in the functions is a dimensioned variable without specifying index or range of indices all the variable elements are used. The index or range of indices specified determine the elements to be considered.

If a range of indices is given, such that there is no element in the list of variables to be searched for (find(RECHERCHE, VALEURS(1..0)) for example) the result returned is 0.

The result is an Integer type.

 

Associated errors

Error

Description

ERMODE (10)

The indices given are not numerical.

ERINDI ( 8)

Error in limits for indices.

ERDOM (50)

The arguments are not the same type, or no value is found in the list (for find(VALEURS(1..0)) for example).

ERDIM (55)

Too many dimensions given.

 

Associated key words

MAX - MIN - SUM - PRD - AVG - VAR - UNI


CONTENTS


Copyright © Sage 1999 - 2007