Porovnávané verzie

Kľúč

  • Tento riadok sa pridal
  • Riadok je odstránený.
  • Formátovanie sa zmenilo.

FIND_TRUE action


Function
The actions is searching for a value of a local variable, for which the given expression gets the value @TRUE.


Declaration


Blok kódu
languageesl
themeConfluence
 FIND_TRUE _index, maxIndex, _retCode, find expression 


Parameters


_indexin/outIdentifier (local variable) of Int type. Control variable for expression.
maxIndexinIdentifier (local variable) of Int type. Maximal value of the control variable.
_retCodeoutIdentifier of Int type - return code.
find expressioninExpression of BOOL type.


Description
The action progressively increases a value of the local control value _index by +1. It evaluates the expression find expression before each increasing of the value. If the expression gets the value @TRUE, the action is to be terminated and the control value  _index contains the given value. If the expression is not to be evaluated successfully (invalid values, ...), the variable _retCode will contain the error type, otherwise _ERR_NO_ERROR. If the expression find expression does not get the value @TRUE within all permitted range, the value of the variable _index will be maxIndex+1 after the action termination.

It is necessary, to make the expression find expression dependent on a value of the control value. If not, the action generates the error _ERR_LOCAL_VAR_NFOUND.

As you can see be seen in the example, the action may be taken advantage for can be advantageously used when searching structures.

Example


Blok kódu
languageesl
themeRDark
RECORD (SD.RecordDef) _struct
 INT _index
 INT _maxIndex
 INT _retCode
 
....
 
 ; search for a row containing the text "hello" in the column Text
 _index := 1           ; search from the first row
 _maxIndex := _struct\DIM
 
 
FIND_TRUE _index, _maxIndex, _retCode, _struct[_index]^Text="hello"
 IF _retCode # _ERR_NO_ERROR THEN
 
   ; the error retCode occurred in row index
 
ELSIF _index = _maxIndex+1 THEN
 
  ; required row not found
 
ELSE
 
  ; the row_index contains the text "hello" in the column Text
 
ENDIF



Info
titleRelated pages:

Script actions