String Operations

<< Click to Display Table of Contents >>

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

String Operations

STR.GrabSingle

Previous Top Next


MiniRobotLanguage (MRL)

 

STR.GrabSingle

Extract a Specific Field from a Delimited String, using one (optinal multiple Character) Delimiter

 

 

clip0865

Result from the Script below. Note the difference between ".," and ",."

 

 

 

 

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.

This delimiter can have multiple characters.

The result is either placed on the Top of Stack (TOS) or in an optional variable (P4).

 

If you want to use a command that accepts multiple SIngle-character delimiters, use STR.GrabDelimited instead.

 

 

Syntax

 

 

STR.GrabSingle|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 applies will treat the characters in P3 together as one SIngle or multi-character delimiter delimiter.          

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.GrabSingle|$$SRC|$$LVA|,.|$$REA

$$LVA=2

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

$$LVA=3

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

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

ENR.

 

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also: