<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > String Operations |
MiniRobotLanguage (MRL)
GSC. Command
Get Substring/Delimiter Count
Intention
Returns the number of occurences of a given substring or delimiter within a main-string.
There are several modes of operation. General usage is easy:
GSC.$$MAI|$$SUB
DBP.Result is: $$000
Which will get the number of delimiters. You can also count the number of delimited elements by adding the flag "d".
GSC.$$MAI|$$SUB||d
DBP.Result is: $$000
If you add the flag "a" the nany of the elemnts in P2 will be treated as delimiter. Like this:
$$MAI=Ralf,Peter;Mark.Paul
$$SUB=;,.
GSC.$$MAI|$$SUB||da
DBP.Result is: $$000
Syntax
GSC.P1|P2[|P3][|P4]
Parameter Explanation
P1 - Main-String
P2 - Sub-String/Delimiter
P3 - (optional) Variable for the result of the operation.
If omitted, TOS is used.
P4 - (optional) Flags. Can be any or all of the following letters:
"a" - then ANY of the characters in P2 is been treated
as delimiter/string to count.
"d" - then elements are counted, rather then delimiters,
result will be higher.
"e" - equal-case-mode is switched on
Example
'***********************************
' GSC.-Sample
' Count delimited Elements
'***********************************
' Use Elements-Coint Flag: "d"
$$MAI=Haus;Ochse;Karl
$$SUB=;
GSC.$$MAI|$$SUB||d
DBP.Result is: $$000
ENR.
'***********************************
' GSC.-Sample 2
' Count delimiters
'***********************************
' Use Elements-Coint Flag: "d"
$$MAI=Haus;Ochse;Karl
$$SUB=;
GSC.$$MAI|$$SUB
DBP.Result is: $$000
ENR.
Remarks
-
Limitations:
-
See also:
• 1.5.2 Working with Text-Strings
• SBD. - String between Delimiter
• SBM. - String between Delimiter-Multiple
• VAR. - Variable Set Value/Clear
• IVS. / NVS. - If-Variable-String