String Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > String commands > !BLO.-Block-Commands > Block Information >

String Operations

BLO.BlockCount

Previous Top Next


MiniRobotLanguage (MRL)

 

BLO.BlockCount

Counts the number of top-level blocks.

 

Intention

 

This command counts how many complete, top-level blocks exist in a string.

It is useful for determining the size of a list or the number of records before starting a loop. It intelligently ignores any nested blocks, providing an accurate count of only the main, parent-level blocks.

Will only work is start- and End-Delimiter are NOT the same.

 

 

                         Counting Top-Level Blocks

 

               ┌────────────┐    ┌─────────────────────────┐         ┌──────────┐

Counted:         Block 1         Block 2 (ignores nested)             Block 3

Source String:  <ITEM>A</ITEM>   <ITEM><SUB>a</SUB></ITEM>          <ITEM>C</ITEM>

               └────────────┘    └─────────────────────────┘         └──────────┘

 

               Result: 3

 

 

Syntax

 

BLO.BlockCount|P1|P2|P3[|P4]

 

Parameter Explanation

 

P1 - (Input, Text) The source string to search within.

P2 - (Input, Text) The starting delimiter string.

P3 - (Input, Text) The ending delimiter string.

P4 - (Output, Numeric) Optional. Variable to store the resulting count. If omitted, the count is placed on the Top of Stack (TOS).

 

Example

 

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

' BLO.BlockCount Example

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

' This string contains two top-level blocks.

$$SRC=AaB

BLO.BlockCount|$$SRC|''|''|$$COUNT

' $$COUNT will be 2

MBX.Found $$COUNT top-level items.

ENR.