<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !DIC.-Delimited Item Commands > DIC.Set_Value |
MiniRobotLanguage (MRL)
DIC.Set_Value
Set a Value of a specified Field from a Delimited String to another specified value
Intention
Assume you have a TAB-delimited Line like this:
2022/07/19 03:44:06 -32.4 -45 .15.00 +56.00 5 377
Now, you decide that you want to change the Column 5 to this value: XI
' This is the delimiter character
VAR.$$DEL=;
' This is the Line that has delimited items and will be changed
VAR.2022/07/19 03:44:06$tab$-32.4$tab$-45$tab$.15.00$tab$+56.00$tab$5$tab$377
' This is the Index of the Elements that we want to set the value for.
VAR.$$INX=5
' This is the values that will be set into the field
VAR.$$VAL=XI
' Now we call the command
DIC.set|$$REF|$$DEL|$$INX|$$VAL
' And Debug-Print the Result
DBP.$$LIN
ENR.
And this is the result:
2022/07/19 03:44:06 -32.4 -45 XI +56.00 5 377
Before: 2022/07/19 03:44:06 -32.4 -45 .15.00 +56.00 5 377
After: 2022/07/19 03:44:06 -32.4 -45 XI +56.00 5 377
Syntax
DIC.Set_Value|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 Field to be changed. Can be Single number like 1 or can be an Letter like "A".
P4 - Variable with values to set into the field that is specified by P3.
P5 - (optional) Variable for Result. If omitted result is placed in P1 overwriting the original line..
Example
'***********************************
' DIC.Set - 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