Smart Package Robot 's Collection Commands

<< Click to Display Table of Contents >>

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

 Smart Package Robot 's Collection Commands

JIU. - Jump If Unique

Previous Top Next


MiniRobotLanguage (MRL)

 

JIU.Command

Jump If Unique (not in the specified Collection)

 

 

Intention

 

The JIU. command is designed to control the flow of your script based on the uniqueness of an element within a specified collection.

Specifically, it will cause a jump in the script if the specified element is not already present in the targeted collection.

This makes JIU. particularly useful for testing if elements are already in a collection.

 

JIU. stands for "Jump If Unique" and is used to verify whether an element would be a new, unique addition to a collection.

If the element is already in the collection, indicating it is not unique, the script continues without jumping.

If the element is not in the collection, indicating it would be a unique addition, the script jumps to the specified label.

 

 

 

Syntax

 

JIU.P1|P2|P3

 

 

 

Parameter Explanation

 

P1 - The collection identifier, a numeric value indicating the target collection.*

P2 - The element to check for uniqueness within the specified collection.

P3 - The label to jump to if the element is not present in the collection, indicating it is unique and could be added.

 

 

*Collection Type 1: "Word-Collections".

They are numbered from 0 to 1024.

 

Collection Type 2: "Checksum-Collections".

They are numbered from 1025 to 2048.

 

 

Example

 

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

' Advanced Collection Management Testing Script

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

 

' Set the identifier for the collection to be used

VAR.$$CNU=1027

 

' Start a loop to simulate generating and processing multiple prenames

FOR.$$LC3|1|10

  

  ' Generate a prename and assign it to variable $$NAM

  TST.Generate PreName|$$NAM

  ' Log the generated prename

  DBP.Append Generated prename: $$NAM

 

  ' Check if the prename $$NAM is unique in the collection $$CNU

  JIU.$$CNU|$$NAM|name_is_unique

    ' If the prename is not unique, log the event and skip adding

  DBP.Append $$NAM is already in Collection $$CNU, skipping.

  JMP.continue_loop

  :name_is_unique

    ' If the prename is unique, add it to the collection

  ATC.$$CNU|$$NAM

    ' Log the successful addition

  DBP.Append Added $$NAM to Collection $$CNU.

 

  :continue_loop

  ' Get and output the updated count of elements in the collection

  CGC.$$CNU|$$NUA

  DBP.Current size of Collection $$CNU: $$NUA elements.

 

  ' Generate a decision point to simulate various collection manipulations

  RND.1|3|$$DEC

  IVV.$$DEC=1

    ' Case 1: Try to re-add the same prename to check for duplicates

    ATC.$$CNU|$$NAM

    DBP.Append Re-attempted to add $$NAM to Collection $$CNU.

  EIF.

  IVV.$$DEC=2

    ' Case 2: Remove the prename from the collection

    RFC.$$CNU|$$NAM

    DBP.Append Removed $$NAM from Collection $$CNU.

  EIF.

  IVV.$$DEC=3

    ' Case 3: Check if the prename was actually removed

    JNU.$$CNU|$$NAM|name_not_unique

    DBP.Append Verified that $$NAM is no longer in Collection $$CNU.

    :name_not_unique

    DBP.Append $$NAM is still in Collection $$CNU.

  EIF.

 

  ' End of current loop iteration

NEX.

 

' End of loop - clean up the collection

CLC.$$CNU

DBP.Collection $$CNU has been cleared.

MBX.!

ENR.

 

 

 

 

 

 

Remarks

 

-

 

 

Limitations:

Currently the Smart Package Robot supports 1025 Collections that are numbered from 0 to 1024 and Type 2 -"Checksum"-Collections from 1025 to 2048.

Type 1 Collections are groups of character strings that are separated by a null byte. Therefore Elements must never Contain a CHR(0) (Null-Byte).

Type 2 Collections will contain a 16 Byte Checksum of an Element and do not have any delimiter.

 

 

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