<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !DIC.-Delimited Item Commands > DIC.Get_in_Order |
MiniRobotLanguage (MRL)
DIC.Get_in_Order
Get specified Fields from a Delimited String in the Order of the List-Parameter
Intention
Assume you have a Line like this:
AA;BB;CC;DD;EE;FF
as you can read it Line-by-line out of a csv.-file
Now, you decide that you only need the Columns 3,5,1,6 and 4 in this order.
Note that with this command, you can specify the Columns in the order that will be in the result.
' This is the delimiter character
VAR.$$DEL=;
' This is the Line that has delimited items
VAR.$$LIN=AA;BB;CC;DD;EE;FF
' This is the Index-List with the Elements that we want to get in the result
VAR.$$IND="C","E",1,6,4
' Now we call the command
DIC.Geo|$$DEL|$$LIN|$$IND|$$RES
' And Debug-Print the Result
DBP.$$RES
ENR
And this is the result: CC;EE;AA;FF;DD
Syntax
DIC.Get_in_Order|P1|P2|P3[|P4]
Parameter Explanation
P1 - Delimiter, can be a Single character like semicolon or multiple characters like $crlf$. This is the specified delimiter that delimits the fields in the specified Line P2.
P2 - Line with delimited Items.
P3 - Variable with Index of Fields to get. Can be Single number like 1 or can be an Letter like "A". You can give a comma-separated list with Numbers of the fields to get.
P4 - (optional) Variable for Result. If omitted result is placed on TOS.
Example
'***********************************
' DIC.Geo - Sample
'***********************************
' This is the delimiter character
VAR.$$DEL=;
' This is the Line that has delimited items
VAR.$$LIN=AA;BB;CC;DD;EE;FF
' This is the Index-List with the Elements that we want to get in the result
VAR.$$IND="C","E",1,6,4
' Now we call the command
DIC.Geo|$$DEL|$$LIN|$$IND|$$RES
' And Debug-Print the Result
DBP.$$RES
' Result:
' CC;EE;AA;FF;DD
ENR
Remarks
-
Limitations:
-
See also:
•1.5.2 Working with Text-Strings
•VAR. - Variable Set Value/Clear
•IVS. / NVS. - If-Variable-String
•SBD. - String between Delimiter
•SBM. - String between Delimiter-Multiple