String Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > String commands > !STR.- String Command >

String Operations

STR.GrabDelimited

Previous Top Next


MiniRobotLanguage (MRL)

 

STR.GrabDelimited

Extract a Specific Field from a Delimited String, using one or multiple Single-Character Delimiters

 

 

clip0864

Result from the Script below.

 

 

 

Intention

 

While there are lots of commands especially for handling of delimited Strings, here is another one, in the STR.-Section.

This command extracts a specific field (P2) from a delimited source string (P1). The delimiter can be optionally specified (P3), and the default is a comma. The result is either placed on the Top of Stack (TOS) or in an optional variable (P4).

 

          This command applies ANY on the delimiters in P3, means ANY of the characters in P3 will be treated as a possible delimiter.
          if you use a Single "multi-character delimiter" you can not use this command.

 

 

 

 

Syntax

 

 

STR.GrabDelimited|P1|P2[|P3|P4]

 

 

 

Parameter Explanation

 

P1 - (Source String) The string from which to extract the field.

P2 - (Field Index) The index of the field to grab from the source string.

P3 - (Optional) Delimiter string. If omitted, the default is a comma.

          This command will treat ANY of the characters in P3 as a delimiter.
          if you use a Single "multi-character delimiter" you can not use this command. Use STR.GrabSingle instead.

P4 - (Optional) Variable for storing the result. If omitted, the result is placed on TOS.

 

 

 

 

Example

 

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

' STR.-Sample

'***********************************
$$SRC=Hello,this,new,world

$$LVA=1

STR.GrabDelimited|$$SRC|$$LVA|,|$$REA

$$LVA=2

STR.GrabDelimited|$$SRC|$$LVA|,|$$REB

$$LVA=3

STR.GrabDelimited|$$SRC|$$LVA|,|$$REC

MBX.$$REA$crlf$ $$REB$crlf$ $$REC

ENR.

 

 

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also: