|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !BLO.-Block-Commands > Block Extraction > String Operations |
MiniRobotLanguage (MRL)
BLO.BlockGetNth
Gets the Nth complete top-level block.

Intention
This command finds a specific block by its order of appearance in the string.
It counts only complete, top-level blocks, correctly ignoring any nested blocks when determining the count.
This allows you to precisely target an element in a sequence of blocks.
Finding the 2nd Top-Level Block
Block 1 Block 2
┌──────────────┐ ┌──────────────┐
Source String: <MSG>Hello</MSG> <MSG>World</MSG> <MSG>Again</MSG>
▲ ▲
│ │
N=2 finds this block: -----------┘ └----------
Result: "<MSG>World</MSG>"
Syntax
BLO.BlockGetNth|P1|P2|P3|P4|P5
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 - (Input, Numeric) The 1-based index of the block to retrieve (e.g., 2 for the second block).
•P5 - (Output, Text) Variable to store the resulting full block (including delimiters).
Example
'***********************************
' BLO.BlockGetNth Example
'***********************************
$$SRC=[ITEM]Apple[END] [ITEM]Orange[END] [ITEM]Pear[END]
' Get the 2nd block
BLO.BlockGetNth|$$SRC|[ITEM]|[END]|2|$$RES
' $$RES will now contain "[ITEM]Orange[END]"
MBX.$$RES
ENR.
Remarks
• If the requested block number is greater than the number of available top-level blocks, an empty string is returned.
See also:
• BLO.BlockGetNthEx - Gets Nth block with extended info
• BLO.BlockGetAll - Gets all top-level blocks into an ARR array