<< Click to Display Table of Contents >> Navigation: 3. Script Language > TXT. Text-File Engine > CSV-Related Commands > Delimited_Items_Swap |
MiniRobotLanguage (MRL)
TXT.Delimited_Items_Swap
TXT.dis
Exchange two Fields inside a Delimited String, similar to DIC.Swap, but process the whole TXT.-Buffer, not just a line.
Intention
This command does the same like DIC.Swap but will process the whole TXT.-Buffer "Line by Line".
Therefore it does not need an Line-Specifier.
The following Sample is from DIC.Swap
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 want to insert Columns before "A" and before "E".
' This is the delimiter character
VAR.$$DEL=;
' This is the Line that has delimited items
VAR.$$LIN=AA;BB;CC;DD;EE;FF$crlf$
VAV.$$LIM=$$LIN$$LIN$$LIN
TXT.Load_Pure_Text|$$LIM
' Theseare the two fields to be exchanged
VAR.$$INA="A"
VAR.$$INB="E"
' Now we call the command
TXT.dis|$$DEL|$$INA|$$INB
' And Save the Result
$$OUT=?exeloc\Result.txt
TXT.Save_File|$$OUT
ENR.
And this is the result:
EE;BB;CC;DD;AA;FF
EE;BB;CC;DD;AA;FF
EE;BB;CC;DD;AA;FF
Syntax
TXT.Dis|P1|P2|P3
TXT.Delimited_Items_Swap|P1|P2|P3
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..
P2 - Variable with Index of Fields A to Swap with Field in P3.
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.
P3 - Variable with Index of Fields B to Swap with Field in P2.
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.
Example
'***********************************
' DIC.Swap - Sample
'***********************************
' This is the delimiter character
VAR.$$DEL=;
' This is the Line that has delimited items
VAR.$$LIN=AA;BB;CC;DD;EE;FF
' Theseare the two fields to be exchanged
VAR.$$INA="A"
VAR.$$INB="E"
' Now we call the command
DIC.Swap|$$DEL|$$LIN|$$INA|$$INB|$$RES
' And Debug-Print the Result
DBP.$$RES
' Result:
' EE;BB;CC;DD;AA;FF
ENR
Remarks
This command is currently not optimized for very large Tables with 100.000's of lines.
Using it for very large tables may lead to significant waiting times.
Limitations:
-
See also:
• 1.5.2 Working with Text-Strings
• VAR. - Variable Set Value/Clear
• IVS. / NVS. - If-Variable-String
• SBD. - String between Delimiter