<< Click to Display Table of Contents >> Navigation: 3. Script Language > Variable Definitions and Operations > Data-Block Commands > Data-Block Commands |
MiniRobotLanguage (MRL)
CNB. Command
Create New Block
Intention
What is a "data-block" ?
A data-block is a compound variable. A variable that contains multiple independent variables inside.
How do i create a data-block?
Use CNB. to create a new data-block container.
More on the CNB.-command:
This command is used to create a new data-block. Using data-blocks, any variable can be used to store multiple data items.
Using CNB. you can create a data item out of up to 20 data items in one step.
' Create a block with 3 elements
CNB.$$BLO|3|Element 1|Element 2|Element 3
' retrieve element Nr.1 into $$RES
GBE.$$BLO|1|$$RES
' Debug-Print the element in the editor
DBP.$$RES
ENR.
If you want to haven more then 20 data-items in the block, you need to create the block first, and add the items in a second step. Like this:
CNB.$$BLO|30
FOR.$$CNT|1|30
VAR.$$ELE=Data-Item $$CNT
SBE.$$BLO|$$CNT|$$ELE
NEX.
' Now see if they are really in there
FOR.$$CNT|1|30
GBE.$$BLO|$$CNT|$$ELE
DBP. ELement $$CNT=>$$ELE
NEX.
ENR.
There is no need to know perfectly how many block you will have at the end.
You can at any time extend (increase) the number of items in a data-block, without any items in that data-block being lost.
Extending a data-block is done using SIB. or SBE.
For more details on 1.5.1.5. Organizing data items in blocks see there.
Syntax
CNB.P1|P2[|P3]...[|PX]
Parameter Explanation
CNB.P1|P2
In this case P1 is taken as Block-variable, P2 is the number of the blocks to create. After creation, all blocks are there, while empty.
CNB.P1|P2[|P3 ... Px]
In this case P1 is taken as Block-variable, P2 is the number of the blocks to create. All further variables fill the blocks starting at block Nr. 1. This way you can create and define small blocks in one strike.
Example
'**********************************************
' GBE./CNB. - Sample
' Small block created in one strike
' with only 3 items
'**********************************************
CNB.$$BLO|3|Element 1|Element 2|Element 3
FOR.$$CNT|0|2
GBE.$$BLO|($$CNT+1)|$$RES
DBP.Element $$CNT is $$RES
NEX.
ENR.
'**********************************************
' SBE./CNB. - Sample 2
' Larger Block with >20 Items
'**********************************************
CNB.$$BLO|30
FOR.$$CNT|1|30
VAR.$$ELE=Data-Item $$CNT
SBE.$$BLO|$$CNT|$$ELE
NEX.
' Now see if they are really in there
FOR.$$CNT|1|30
GBE.$$BLO|$$CNT|$$ELE
DBP. ELement $$CNT=>$$ELE
NEX.
ENR.
Remarks
Blocks are internally checked for authenticity. This is done to prevent hard to track error.
If you change bytes or the length of a block variable externally, the block will not be unpacked anymore.
Data blocks can contain all 256 ASC Characters (even binary files) and are binary-compatible. Therefore whether special folders nor system variables are resolved inside blocks. Variables are resolved one time.
Limitations:
There is no explicit limit on data-items per block. However timing considerations may set you a limit at around 10000 Items, depending on your available hardware. For a larger number of non-binary items, Member-Operations, using SBD. FEM. and SBM. may be significantly faster.
See also:
• 1.5.1.5. Organizing data items in blocks
•