<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !STR.- String Command > String Operations |
MiniRobotLanguage (MRL)
STR.OVERWRITE
String commands
Intention
OVERWRITE - Mode: This Mode will patch the Source String with a second Patch String. It will "overwrite" the Source String, while it will never change the total length of the Source String.
Here is an example:
We want to OVERWRITE the two "XX" in the Source String with the missing numbers "67".
The result is just that. In real life, you can use this command for example to patch binary files. OVERWRITE will take care that the overall length of the file is never changed, and that no content in the file is been moved. It will just "overwrite" some content with your content.
You can specify negative numbers as positional parameter. In this case, the position will be calculated from the end of the source string:
VAR.$$SRC=12345XX89
VAR.$$NEW=67
' - 2 => Second byte from end of the string
VAR.$$POS=-2
STR.OVERW|$$SRC|$$POS|$$NEW
MBX.$$SRC
ENR.
Like in this example.
To Replace bytes in a String, use the RPL. - RePLace in String command.
To extract a part out of a String, use the GSS. - GetSplitString command.
If your String is a delimited String (like a .csv-file), use:
• SBD. - String between Delimiter
• SBM. - String between Delimiter-Multiple
Syntax
STR.OVERWRITE|P2|P3
Parameter Explanation
P1 - source and destination variable
P2 - numeric parameter, will be completely resolved. This is
the start-byte. Its the first byte that will be overwritten
with the target string P3. You can specify a negative value
for P2 then the position will be calculated from the end of
the string (reverse direction).
P3 - Overwrite-String, must have a length larger then zero.
Example
'*************************************
' STR.OVERWRITE
'*************************************
VAR.$$SRC=12345XX89
VAR.$$NEW=67
VAR.$$POS=6
STR.OVERW|$$SRC|$$POS|$$NEW
MBX.$$SRC
ENR.
'*************************************
' STR.OVERWRITE, negative position
'*************************************
VAR.$$SRC=12345XX89
VAR.$$NEW=67
VAR.$$POS=-2
STR.OVERW|$$SRC|$$POS|$$NEW
MBX.$$SRC
ENR.
Remarks
Variables inside the source P1 are only resolved once. Therefore it can be safely used for binary data. Specialfolders and systemvariables etc. are not resolved, to avoid unwanted changes in binary data..
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