|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !BLO.-Block-Commands > Block Information > String Operations |
MiniRobotLanguage (MRL)
BLO.BlockValidate
Checks if all block delimiters are balanced.
Intention
This command analyzes a string to determine if its delimited blocks are well-formed. It checks that every start delimiter has a corresponding end delimiter and that there are no extra, mismatched end delimiters. This is a crucial diagnostic tool before performing complex parsing operations.
Validating Block Structure
Case 1: Balanced (OK)
[A[B]C]
Level: 1 2 1 0 -> Final Level = 0. Result: 0
Case 2: Unclosed (Error)
[A[B]
Level: 1 2 -> Final Level = 2. Result: 2
Case 3: Mismatched (Error)
[A]]
Level: 1 0 -1 -> Final Level = -1. Result: -1
Syntax
BLO.BlockValidate|P1|P2|P3[|P4]
Parameter Explanation
•P1 - (Input, Text) The source string to validate.
•P2 - (Input, Text) The starting delimiter string.
•P3 - (Input, Text) The ending delimiter string.
•P4 - (Output, Numeric) Optional. Variable to store the numeric result. If omitted, the result is placed on the Top of Stack (TOS).
Return Values
•0: The string is perfectly balanced.
•Positive Number: Indicates the number of unclosed start delimiters. (e.g., 1 means one block was left open).
•Negative Number: Indicates the number of mismatched end delimiters. (e.g., -1 means one extra closing tag was found).
Example
'***********************************
' BLO.BlockValidate Example
'***********************************
$$SRC=[A[B]]
BLO.BlockValidate|$$SRC|'['|']'|$$STATUS
' $$STATUS will be 1, because the [A block is not closed.
MBX.Validation Status: $$STATUS
ENR.
See also:
• BLO.BlockRepair - Repairs strings with unclosed/mismatched blocks