String Operations

<< Click to Display Table of Contents >>

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

String Operations

BLO.BlockGetFirstEx

Previous Top Next


MiniRobotLanguage (MRL)

 

BLO.BlockGetFirstEx

Gets first block with extended info (pos, status).

 

clip1141

 

 

Intention

 

This command performs the same core function as BLO.BlockGetFirst, but provides much more detail about the result.

In addition to the block itself, it returns the block's content (without delimiters), its starting position, and a status code indicating success or the specific reason for failure (e.g., an unclosed block).

 

 

 

                   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]:   ---┘

 

 

 

 

Syntax

 

BLO.BlockGetFirstEx|P1|P2|P3|P4[|P5][|P6][|P7]

 

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 full block string.

P5 - (Output, Text) Optional. Variable to store the content *inside* the block.

P6 - (Output, Numeric) Optional. Variable to store the block's 1-based start position.

P7 - (Output, Numeric) Optional. Variable to store the numeric status code.
0 = OK, block found.
1 = Block not found.
2 = Block was started but never closed.
3 = Delimiters were empty/invalid.

 

 

 

Example

 

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

' BLO.BlockGetFirstEx Example

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

$$BEG=[BEG]

$$END=[/END]

$$SRC=I need to make sure all three questions are covered in a natural way. Let me check if these alternatives capture the original intent without repeating the same words. Also, the user wants the answer between [BEG] and [/END], so no extra text. Alright, combining them into one sentence might work: "How would you introduce yourself, by what moniker are you recognized, and whom do you acknowledge as your paternal figure?" That flows well and rephrases each part appropriately.

$$SRC+[BEG]Could you describe your identity, share the designation used for you, and indicate who holds the role of your paternal progenitor?[/END]

 

BLO.BlockGetFirstEx|$$SRC|$$BEG|$$END|$$OUT|$$CON|$$POS|$$STA

PRT. $$OUT will be "[BEG] and [/END]"

PRT. $$CON will be "and"

PRT. $$POS will be 208

PRT. $$STA will be 0

MBX.Content is: $$CON

ENR.

 

 

Remarks

 

This is the recommended function for complex parsing, as the status code allows your script to react to different failure conditions.

 

See also:

 

BLO.BlockGetFirst - Gets the first complete top-level block

Str-BlockGetLast