|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !STR.- String Command > Clip String Commands > String Operations |
MiniRobotLanguage (MRL)
STR.DeleteTo
Deletes from a position to the end of the string.
Intention
This Command truncates a string at a specified position, removing everything from that position to the end. It is essentially a shortcut for keeping only the leftmost N-1 characters.
Useful for truncating text to a maximum length or removing trailing content.
Syntax
STR.DeleteTo|P1|P2|P3
Parameter Explanation
•P1 - (Input, Text) The source string to modify.
•P2 - (Input, Numeric) The position (1-based) from which to delete to the end.
•P3 - (Output, Text) Variable to store the resulting string.
Deleting to End of String
1 5 10 15
Source String: "Hello World Text"
?
DeleteTo position 7: +----------+
Result: "Hello "
Example
'***********************************
' STR.DeleteTo Example
'***********************************
$$SRC="Hello World Unwanted Text"
' Keep only "Hello World"
STR.DeleteTo|$$SRC|12|$$RES
' $$RES = "Hello World"
MBX.$$RES
' Truncate to 50 characters max
$$LONG="This is a very long string that needs to be truncated..."
STR.DeleteTo|$$LONG|51|$$SHORT
' $$SHORT contains only first 50 chars
MBX.$$SHORT
ENR.
Remarks
? If P2 <= 1, the result will be an empty string.
? If P2 > length of string, the entire string is returned unchanged.
? Equivalent to STR.Left|P1|P2-1|P3 but more explicit about the operation.
See also:
? STR.Delete - Delete a specific range
? STR.Left - Get left N characters
? STR.ClipRight - Remove N characters from right