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

JNU. - Jump If Not Unique

Previous Top Next


MiniRobotLanguage (MRL)

 

JNU. - Command

Jump if not Unique (if Element is already in specified Collection)

 

 

Intention

 

The JNU. 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 already present in the targeted collection.

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

 

JIU. stands for "Jump If Not 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 with jumping to P3.

If the element is not in the collection, indicating it would be a unique addition, the script just continues with the next line.

 

 

Syntax

 

 

JNU.P1|P2|P3

 

 

Parameter Explanation

 

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

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

P3 - The label to jump to if the element is already present in the collection, indicating it is not unique and could not 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

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

'--- Testing with Collection 0 ---

DBP.Testing with collection number 0.

 

' Initialize collection 0 and ensure it's empty

VAR.$$C00=0

CLC.$$C00

DBP.Collection 0 cleared.

 

' Add a unique name to the collection

VAR.$$N10=John

ATC.$$C00|$$N10

DBP.John added to collection 0.

 

' Test uniqueness before attempting to add John again

JIU.$$C00|$$N10|john_is_unique

  ' John is already in the collection

DBP.John is considered not unique.

JMP.continue_test

:john_is_unique

  ' This should not execute because John is already in the collection

DBP.John is unexpectedly considered not in the collection.

 

:continue_test

' Attempt to add John again to test ATC.'s prevention of duplicates

ATC.$$C00|$$N10

' Check the count to confirm John wasn't added again

CGC.$$C00|$$CT0

IVV.$$CT0=1

  DBP.Correct, John was not added again, collection has $$CT0 names.

ELS.

  DBP.Error: Duplicate John was added.

EIF.

 

' Add another unique name, Jane, to the collection

VAR.$$N20=Jane

ATC.$$C00|$$N20

DBP.Jane added to collection 0.

 

'--- Testing with Collection 1027 ---

DBP.Testing with collection number 1027 (beyond standard range).

 

' Assuming collections beyond 1024 are handled, initialize collection 1027 and clear it

VAR.$$C27=1027

CLC.$$C27

DBP.Collection 1027 cleared. (Note: Assumes handling beyond standard range.)

 

' Add a name to collection 1027

VAR.$$N27=Alice

ATC.$$C27|$$N27

DBP.Alice added to collection 1027.

 

' Test uniqueness with JNU. before removing Alice

JNU.$$C27|$$N27|alice_not_unique

' This part should be skipped since Alice was initially added

DBP.Alice unexpectedly considered not in the collection.

:alice_not_unique  

  ' Since Alice is in the collection, this should execute

DBP.Alice is confirmed in the collection.

  ' Remove Alice to test RFC.

RFC.$$C27|$$N27

DBP.Alice removed from collection 1027.

' Finalize script with confirmation message

MBX.Collection command tests completed.

 

' End of script

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