|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !BLO.-Block-Commands > Block Manipulation > String Operations |
MiniRobotLanguage (MRL)
BLO.BlockReplaceBlock
Replaces the entire Nth block (with delimiters).
Intention
This command targets the Nth top-level block in a string and replaces the entire block—including its start and end delimiters—with a new string. This is useful for substituting a complete element in a list with something else entirely.
Replacing Block Content
Source String: [header]TITLE[/header]
└──┬──┘
│ replacement="New Title"
▼
Result: [header]New Title[/header]
Syntax
BLO.BlockReplaceBlock|P1|P2|P3|P4|P5[|P6]
Parameter Explanation
•P1 - (Input/Output, Text) The variable containing the source string.
•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 replace.
•P5 - (Input, Text) The new string to insert in place of the entire block.
•P6 - (Output, Text) Optional. A different variable to store the modified string. If omitted, P1 is modified in place.
Example
'***********************************
' BLO.BlockReplaceBlock Example
'***********************************
$$SRC=[ITEM]Apple[END] [ITEM]Orange[END]
' Replace the first block entirely
BLO.BlockReplaceBlock|$$SRC|"[ITEM]"|"[END]"|1|"{NEW_ITEM}"
' $$SRC now contains "{NEW_ITEM} [ITEM]Orange[END]"
MBX.$$SRC
ENR.