|
<< 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 |
MiniRobotLanguage (MRL)
IIC. / NIC. - If Item in Collection
If Result available
Intention
The IIC. command checks if a specified item ($$ITM) is present in the specified collection. The search is generally case sensitive unless P3 is given.
If the item is found within the collection, the script continues to execute the immediately following commands until an ELS. or EIF. is encountered.
The NIC. command is the inverse of IIC.; it checks if a specified item is not present in the specified collection.
If the item is not found within the collection, the script executes the immediately following commands until an ELS. or EIF. is encountered.
Syntax
IIC.P1|P2[|P3] … ELS. … EIF.
NIC.P1|P2[|P3] … ELS. … EIF.
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 - (optional) If a 3rd Parameter is given, the search is done case-insensitive.
*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
'************************************************************
' Script Demonstrating IIC. and NIC. Commands
'************************************************************
' Initialize collection 0 and ensure it's empty
VAR.$$C00=0
CLC.$$C00
DBP.Initializing and clearing collection 0.
' Add a unique element to the collection
VAR.$$ITM=John
ATC.$$C00|$$ITM
DBP.Added John to collection 0.
' Check if "John" is in the collection
IIC.$$C00|$$ITM
DBP.John is in the collection.
ELS.
DBP.John is not in the collection.
EIF.
' Prepare another item "Anna" not yet added to the collection
VAR.$$IT2=Anna
' Check if "Anna" is NOT in the collection using NIC.
NIC.$$C00|$$IT2
DBP.Anna is not in the collection, proceeding to add her.
' Add "Anna" to the collection
ATC.$$C00|$$IT2
ELS.
DBP.Anna is unexpectedly found in the collection.
EIF.
DBP.Script concluded. Elements verified.
' End of script
ENR.
'************************************************************
' Complex Script for Dynamic Collection Management
'************************************************************
' Initialize collection 0 and ensure it's empty
VAR.$$C00=0
CLC.$$C00
DBP.Initializing and clearing collection 0.
' Add several elements to the collection
VAR.$$IT1=Apple
ATC.$$C00|$$IT1
VAR.$$IT2=Banana
ATC.$$C00|$$IT2
VAR.$$IT3=Cherry
ATC.$$C00|$$IT3
DBP.Apple, Banana, and Cherry added to collection 0.
' Check if Banana is in the collection using IIC.
IIC.$$C00|$$IT2
DBP.Banana is confirmed to be in the collection.
ELS.
DBP.Banana is not in the collection, which is unexpected.
EIF.
' Remove Banana from the collection
RFC.$$C00|$$IT2
DBP.Banana removed from collection 0.
' Attempt to add Banana again, but first check if it's not in the collection using NIC.
NIC.$$C00|$$IT2
DBP.Banana is not in the collection, proceeding to add.
ATC.$$C00|$$IT2
ELS.
DBP.Banana is unexpectedly found in the collection, not added.
EIF.
' Backup the collection to a variable
CTV.$$C00|$$DAT
DBP.Collection 0 backed up to $$DAT.
' Clear and restore the collection to verify the backup and restore process
CLC.$$C00
DBP.Collection 0 cleared.
CFV.$$C00|$$DAT
DBP.Collection 0 restored from $$DAT.
' Verify the restoration by checking the count of elements
CGC.$$C00|$$CNT
DBP.Collection 0 now contains $$CNT elements post-restoration.
' Verify specific elements' presence post-restoration
' Check for Apple
IIC.$$C00|$$IT1
DBP.Apple is confirmed to be in the collection post-restoration.
ELS.
DBP.Apple is not in the collection post-restoration, which is unexpected.
EIF.
' Check for Cherry
IIC.$$C00|$$IT3
DBP.Cherry is confirmed to be in the collection post-restoration.
ELS.
DBP.Cherry is not in the collection post-restoration, which is unexpected.
EIF.
DBP.Script concluded. Dynamic management of collection 0 demonstrated.
' End of script
ENR.

Script Explanation:
Initialization: The script starts by initializing and clearing collection 0.
Addition: Adds "Apple", "Banana", and "Cherry" to the collection, demonstrating the ATC. command.
Presence Check: Uses IIC. to confirm "Banana" is in the collection before removing it.
Removal and Re-Addition: Removes "Banana" with RFC., then checks its absence with NIC. before adding it back, showcasing conditional element management.
Backup and Restore: The collection's content is backed up to a variable with CTV., then the collection is cleared and restored with CFV., illustrating data preservation techniques.
Verification: Finally, CGC. is used to verify the count of elements in the restored collection, with additional checks using IIC. to confirm the presence of specific elements post-restoration.
Remarks
-
Limitations:
-
See also:
• CFV. - Collection from Variable
• CTV. - Collection to Variable
• RFC. - Remove from Collection