|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !BLO.-Block-Commands > Block Extraction > String Operations |
MiniRobotLanguage (MRL)
BLO.BlockGetNestedNth
Gets a specific nested block within a parent.

Intention
This powerful command allows you to retrieve a block that is nested inside another block. It first identifies the Nth top-level (parent) block, and then searches within that parent's content to find the Nth nested (child) block. This is ideal for extracting a specific field from a specific record in structured text.
Getting a Nested Block
Step 1: Find Parent Block #2
┌───────────────────────────┐
Source String: <ROW>A<D>1</D></ROW> <ROW>B<D>2</D><D>3</D></ROW>
└───────────┬───────────────┘
│
Step 2: Find Nested Block #2 within Parent: --┴--► B<D>2</D><D>3</D>
└─┬──┘
│
▼
Result: "<D>3</D>"
Syntax
BLO.BlockGetNestedNth|P1|P2|P3|P4|P5|P6
Parameter Explanation
•P1 - (Input, Text) The source string to search within.
•P2 - (Input, Text) The starting delimiter. It is used for both parent and nested blocks.
•P3 - (Input, Text) The ending delimiter. It is used for both parent and nested blocks.
•P4 - (Input, Numeric) The 1-based index of the top-level parent block to search inside.
•P5 - (Input, Numeric) The 1-based index of the nested block to find within the parent's content.
•P6 - (Output, Text) Variable to store the resulting nested block (including its delimiters).
Example
'***********************************
' BLO.BlockGetNestedNth Example
'***********************************
' The source contains two parent blocks, each with two nested blocks.
$$SRC=[Parent]A[Data]1[/Data][Data]2[/Data][End] [Parent]B[Data]3[/Data][Data]4[/Data][End]
' Get the 2nd nested block from the 1st parent block.
BLO.BlockGetNestedNth|$$SRC|[Data]|[/Data]|1|2|$$RES
' Note: This example is conceptual. A real use would get the parent content first.
' A better way is to get the parent block first, then search within it.
' 1. Get the first parent block
BLO.BlockGetNth|$$SRC|[Parent]|[End]|1|$$PAR
' 2. Now search within the parent block's content
BLO.BlockGetNth|$$PAR|[Data]|[/Data]|2|$$RES
' $$RES will now contain "[Data]2[/Data]"
MBX.$$RES
ENR.