|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !BLO.-Block-Commands > Block Information > String Operations |
MiniRobotLanguage (MRL)
BLO.BlockRepair
Repairs strings with unclosed/mismatched blocks.
Intention
This command intelligently corrects structural errors in a string containing delimited blocks. It automatically appends closing delimiters for any blocks that were left open, and it removes any extra closing delimiters that do not have a matching opening delimiter. This is extremely useful for sanitizing malformed data before parsing.
Repairing a String
Original String: [A]] [B[C]
▲ ▲
│ └───── Unclosed block
│
└────────── Mismatched end delimiter
Action 1: Remove Mismatched ']'
Result: [A] [B[C]
Action 2: Close Open Blocks at End
Result: [A] [B[C]]
Final Repaired String: "[A] [B[C]]"
Syntax
BLO.BlockRepair|P1|P2|P3[|P4]
Parameter Explanation
•P1 - (Input/Output, Text) The variable containing the string to repair. The result is stored back into this variable if P4 is omitted.
•P2 - (Input, Text) The starting delimiter string.
•P3 - (Input, Text) The ending delimiter string.
•P4 - (Output, Text) Optional. A different variable to store the repaired string.
Example
'***********************************
' BLO.BlockRepair Example
'***********************************
' This string has one unclosed [A] and one extra ]
$$SRC=[A[B]] and one extra ] here.
BLO.BlockRepair|$$SRC|'['|']'|$$REPAIRED
' $$REPAIRED will be "[A[B]] and one extra here.[]"
' Note: A second closing bracket is added to balance the string.
MBX.$$REPAIRED
ENR.
See also:
• BLO.BlockValidate - Checks if all block delimiters are balanced