String Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > String commands > !Delimited Strings >

String Operations

SBM. - String between Delimiter-Multiple

Previous Top Next


MiniRobotLanguage (MRL)

 

SBM. Command

String Between delimiter Multiple

 

 

Intention

 

Return a delimited part of a string. You can specify multiple parts to be returned in one string. For example:
 
  $$VAR=12*3*45*5*67 

  SBM.$$VAR|*|2|4|$$RES

 

  $$RES will be 3*45*5

 

A example for a delimited string is a "csv" file from Excel. It could look like this:

 

VAR.$$TXT=Name,Last Name,Zip-Code

 

In this case the comma is the delimiter. Using the SBM.-command you can get any part of such delimited strings. Usage is like this:

 

VAR.$$TXT=Name,Last Name,Zip-Code

SBM.$$TXT|,|2|3|$$RES

DBP.$$RES

 

Will return "Last name,Zip-Code,", as its the second and the third part in the delimited string. Note that you will find any delimited part in the result aagain delimited with delimiters, even if there were no such delimiters in the source string. This is done to be compatible with empty delimited parts.

 

There is another mode of operation. Imagine the delimiter is a PIPE-Sign "|". Now the PIPE-Sign is the delimiter for the command itself, how could we do that?

 

We can do that with the second operation mode, we use P5. When we specify P5 then we can change the delimiter for the command itself. It's as easy as this:

 

' Here we have a string that is delimited with PIPE's

VAR.$$TXT=Name|Last Name|Zip-Code

' We tell SBD. that we use the comma as command-delimiter (see P5)

SBM.,$$TXT,|,2,$$RES

DBP.$$RES

' Will print: "Last Name|Zip-Code|"

 

As alternative, you can use the RPL.-command and replace all Pipes with something else before using SBM.

 

 

 

 

 

 

Syntax

 

SBM.[P6]P1|P2|P3|P4[|P5]

 

 

Parameter Explanation

 

P1   - STR Source string from which the part should be extracted.

 

P2   - Delimiter inside the source string.

 

P3   - Start-Index of delimited string-item to be extracted

 

P4   - End-Index of delimited string-item to be extracted

 

P5   - Variable for result. If omitted, result goes to TOS.

 

P6   - optional SINGLE CHAR. Delimiter for SBD itself.

     Cannot be "$" or "§". If omitted its "|".

 

 

 

Example

 

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

' SBM.-Demo

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

DBM.2

VAR.$$URA=//Local/www.com/it/berater/org

SBM.$$URA|/|3|4|$$ERG

PRT. Ergebnis von SBM: $$ERG

:enx

MBX.!

END.

 

 

 

Remarks

 

If you have a delimited String and you want to spit all the delimited parts -each into an separate variable, best use SBD. and copy it several times for each delimited part.

 

 

Limitations:

 

-

 

 

See also:

    1.5.2 Working with Text-Strings

    SBD. - String between Delimiter

    FEM. - For Each Member

    VAR. - Variable Set Value/Clear

    IVS. / NVS. - If-Variable-String

    SRT. - Sort Items

    GSS. - GetSplitString

    GES. - Get-Extracted-String

    ! STR. - String Command

    LEN. - Length-of-String