<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !DIC.-Delimited Item Commands > DIC.Set_Multiple |
MiniRobotLanguage (MRL)
DIC.Set_Multiple
Set specified Fields from a Delimited String in the Order of the List-Parameter to other specified values
Intention
Assume you have a TAB-delimited Line like this:
2022/07/19 03:44:06 -32.4 -12.00 -12.00 -17.70 36.70 377
Now, you decide that you want to change the Columns
4,6,5,7 in this order to this values:
-45,+56.00,.15.00,5
Note that with this command, you can specify the Columns in the order that you specify the values in P4.
' This is the delimiter character
VAR.$$DEL=;
' This is the Line that has delimited items and will be changed
VAR.$$LIN=2022/07/19$tab$03:44:06$tab$-32.4$tab$-12.00$tab$-12.00$tab$-17.70$tab$36.70 377
' This is the Index-List with the Elements that we want to set the values for.
' The Order is not iumportant, just that the values in P5 will be matched 1:1 to these Indexes.
VAR.$$IND=4,6,5,7
' These are the values that will be set to these fields
VAR.$$VAL=-45,+56.00,.15.00,5
' Now we call the command
DIC.sem|$$LIN|$$DEL|$$IND|$$VAL
' And Debug-Print the Result
DBP.$$LIN
ENR.
And this is the result:
2022/07/19 03:44:06 -32.4 -45 .15.00 +56.00 5 377
Before: 2022/07/19 03:44:06 -32.4 -12.00 -12.00 -17.70 36.70 377
After: 2022/07/19 03:44:06 -32.4 -45 .15.00 +56.00 5 377
Syntax
DIC.Set_Multiple|P1|P2|P3|P4[|P5]
Parameter Explanation
P1 - Line with delimited Items.
P2 - 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 P1.
P3 - Variable with Index of Fields to be changed. 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 change.
IMPORTANT: The number of Elements in P3 must 1:1 match the number of Elements in P4 else the Command will run into an error and return an empty result.
P4 - Variable with values to set into the fields that are specified by P3.
P5 - (optional) Variable for Result. If omitted result is placed in P1 overwriting the original line..
Example
'***********************************
' DIC.Sem - Sample
'***********************************
VAR.$$LIN=2022/07/19$tab$03:44:06$tab$-32.4$tab$-12.0$tab$-12.0$tab$-17.7$tab$36.7$tab$377
VAR.$$DEL=$tab$
VAR.$$IND=4,6,5,7
VAR.$$VAL=-45,+56.00,.15.00,5
' For more Options see FMT.-Command
VAR.$$FMT=00.00
' Now we call the command
DIC.Format_Numeric|$$LIN|$$DEL|$$IND|$$FMT|$$RES
$$RET=$$RES
DIC.sem|$$RET|$$DEL|$$IND|$$VAL
VAR.$$REF=$$RET
VAR.$$VAL=XI
VAR.$$INX=5
DIC.set|$$REF|$$DEL|$$INX|$$VAL
' And Debug-Print the Result 27
DBP.$crlf$$$LIN$crlf$$$RES$crlf$$$RET$crlf$$$REF
' Output:
' 2022/07/19 03:44:06 -32.4 -12.0 -12.0 -17.7 36.7 377
' 2022/07/19 03:44:06 -32.4 -12.00 -12.00 -17.70 36.70 377
' 2022/07/19 03:44:06 -32.4 -45 .15.00 +56.00 5 377
' 2022/07/19 03:44:06 -32.4 -45 XI +56.00 5 377
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