|
<< 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)
CTV.-Command
Collection/Array To Variable
Intention
CTV. stands for "Collection to Variable". It moves the content from a collection or an Array into a specified variable.
CTV. performs the inverse operation of CFV. / AFV., creating or restoring a collection from the string content of a variable.
Syntax
CTV.P1|P2[|P3]
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 variable containing the string to be moved into the collection. This variable must have been created using CTV.
P3 - (optional) Delimiter (character or string), if omitted, "Binary" is used, only in the "Binary-Mode" you can add all sorts of Elements, otherwise the Elements can never contain the delimiter-character.
*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
'***************************************************************
' Streamlined Testing Script for CTV., CFV., JIU., and JNU. Commands
'***************************************************************
' Initialize collection 0 and ensure it's empty
VAR.$$C00=0
CLC.$$C00
DBP.Initializing and clearing collection 0.
' Add unique elements to the collection
VAR.$$N10=John
ATC.$$C00|$$N10
DBP.Added John to collection 0.
VAR.$$N11=Jane
ATC.$$C00|$$N11
DBP.Added Jane to collection 0.
' Test with JIU. to jump if John is already in the collection (which he is)
JIU.$$C00|$$N10|john_is_in
DBP.John was not added again, proceeding with script.
JMP.verify_jane
:john_is_in
DBP.John is in the collection as expected.
:verify_jane
' Use JIU. to check if Jane is in the collection
JIU.$$C00|$$N11|jane_is_in
DBP.Jane was not added again, proceeding with script.
JMP.add_anna
:jane_is_in
DBP.Jane is in the collection as expected.
:add_anna
' Prepare a new unique element, Anna, not yet in the collection
VAR.$$N13=Anna
' Use JNU. to jump if Anna is not in the collection (she is not)
JNU.$$C00|$$N13|anna_not_in
DBP.Adding Anna to the collection since she is not present.
ATC.$$C00|$$N13
JMP.finish
:anna_not_in
DBP.Error: Anna unexpectedly considered in the collection.
:finish
' Transfer collection 0 to a variable and restore it to verify all elements
CTV.$$C00|$$DAT
CLC.$$C00
CFV.$$C00|$$DAT
DBP.Restored collection 0 from variable. Verifying contents...
' Verify Anna's presence using JIU. after restoration
JIU.$$C00|$$N13|anna_is_in
DBP.Verification failed: Anna should be in the collection.
JMP.end_script
:anna_is_in
DBP.Anna is verified to be in the collection post-restoration.
:end_script
DBP.All elements correctly verified. Test concluded.
' 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:
• CFV. - Collection from Variable
• CTV. - Collection to Variable
• RFC. - Remove from Collection