String Operations

<< Click to Display Table of Contents >>

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

String Operations

BLO.BlockGetFirst

Previous Top Next


MiniRobotLanguage (MRL)

 

BLO.BlockGetFirst

Gets the first complete top-level block.

 

 

clip1140

 

 

Intention

 

This command intelligently finds the first complete block in a string, defined by a start and end delimiter. It correctly handles nested blocks by matching the first start delimiter with its corresponding final end delimiter, ignoring any nested pairs.

This is essential for correctly parsing nested structures like HTML, XML, or bracketed text.

 

 

Syntax

 

BLO.BlockGetFirst|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, Text) Variable to store the resulting full block (including delimiters).

 

 

                   Finding the First Top-Level Block

 

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

                      │                                         │

Source String:     [ITEM] Contents [SUB]Nested[/SUB]     More [END] [ITEM]Second[END]

                     ▲                                          ▲

                     │                                          │

Start Delimiter:     ┘                                          │

                                                                │

End Delimiter matched, skipping the nested [SUB]...[/SUB]:   ---┘

 

Result: "[ITEM] Contents [SUB]Nested[/SUB] More [END]"

 

 

 

Example

 

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

' BLO.BlockGetFirst Example

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

$$SRC=[START]This is the outer block with a [NESTED] block inside.[END] More text.

BLO.BlockGetFirst|$$SRC|[START]|[END]|$$RES

' $$RES correctly contains the full outer block:

' "[START]This is the outer block with a [NESTED] block inside.[END]"

MBX.$$RES

ENR.

 

Remarks

 

This command is the foundation for parsing structured text. It returns an empty string if a complete block cannot be found.

 

See also:

 

BLO.BlockGetFirstEx - Gets first block with extended info

BLO.BlockGetNth - Gets the Nth top-level block