Smart Package Robot 's Collection Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Arrays and Data-Structures > !Collections/Fast Arrays > Fast Array-Commands >

 Smart Package Robot 's Collection Commands

AFE.Array Find Element

Previous Top Next


MiniRobotLanguage (MRL)

 

AFE.Array Find Element

Find Element in Array/Collection, return Element Index or 0

 

 

Intention

 

Using the AFE. command, you can find the Index of any element in an array.

The 4'th parameter allows you to specify whether the Input should be treated as a floating-point integer or a text string, and you can automatically apply trimming, as well as convert to upper or lower case.

These settings in P3 must match the Settings of the Array/Collection especially if "f" or "i" is used, as the Element may not be found otherwise.

This is due to the fact that these options will change the way how an element is stored internally.

This command always searches the entire array or collection and returns the base index, which can be used with the AGE. or ASE. command to access the element.  

 

Please read the general information about Collections and Fast Arrays.  

 

 

 

Syntax

 

 

AFE.P1|P2[|P3][|P4]

 

 

Parameter Explanation

 

P1 - The collection identifier, typically a numeric value or a variable that contains a number from 0 to 1024/1025 to 2048.

P2 - The element to be searched for. This is the raw-Element how it was added to the Array or Collection.

P3 - (Result) Variable to hold the element-index of the element was found, or "0" if he Element was not found. If omitted, TOS is used.

P4 -  (optional) P1 will be processed before performing the search to match the Array/collection we search. Giving wrong parameters here may prevent you from finding the Element.

        Generally these settings should mach the settings of the Array/Collection.

  "f" - floating point number with a range of approximately +/- 3.4*10^-4932 to 1.2*10^4932, and offer 18 digits of precision

  "i" - 64-bit Integer number with a range of -9.22x10^18 to 9.22x10^18 ( -2^63 to 2^63 -1)

  "t" - Trim String before store.

  "l" - Lower-Case-Trim String before store.

  "u" - Upper-Case-Trim String before store.

 You need to use the "f" and "i" options also when you take the Elements out of the Array / Collection if you used them to put the elements in.

 You do not need to use the "t","l" and "u" option two times. You can use them either when you fill the Array or when you take things out.

 

 

 

 

Example

 

'***********************************

' AFE./AGE./ASE.-Sample

'***********************************
' This will reset the Collection "0"

CLC.0

' Now we add the Elements to Collecion 0, Index 1

$$LAA=Hallo Peter

ASE.0|1|$$LAA

 

AFE.0|$$LAA|$$RET

DBP. Element found at: $$RET.

 

' Now we add the Elements to Collecion 0, Index 2

$$LAB=Hallo Max

ASE.0|2|$$LAB

 

AGE.0|1|$$LAC

DBP.$$LAC

 

AGE.0|2|$$LAC

DBP.$$LAC

ENR.

 

 

 

Remarks

 

-

 

 

Limitations:

-

 

See also:

 

ATC. - Add to Collection

CFV. - Collection from Variable

CGC. - Collection Get Count

CLC. - Clear Collection

CTV. - Collection to Variable

JIU. - Jump if Unique

JNU. - Jump Not Unique

RFC. - Remove from Collection