STRPUT Procedure
Inserts the contents of one string into another.
Usage
STRPUT, destination, source[, position]
Input Parameters
destination—The string into which source will be inserted. Must be a named variable of type string. Cannot be an element of an array. If destination is an array, source is inserted into every element.
source—The string to be inserted into destination. Must be scalar.
If not of type string, source is converted to string using PV‑WAVE’s default formatting rules. (These rules are described in the section Free Format Output in Chapter 8 of the PV‑WAVE Programmer’s Guide.)
position—(optional) The character position at which the insertion is begun. If position is omitted or is less than zero, the search begins at the first character (character position 0).
Keywords
None.
Discussion
The source string is inserted into the destination string, starting at the given position. All characters in destination that occur either before the starting position, or after the starting position plus the length of source, remain unchanged.
Example
This example uses STRPUT to insert a substring into a larger string, starting at position 0 of the destination string. Clipping is then demonstrated by using STRPUT to insert a substring that would otherwise extend the length of the destination string.
; Create a string in the variable a.
a = 'Strings are fun'
; Insert the string "PV-WAVE is" into a, starting at position 0.
STRPUT, a, 'PV-WAVE is '
; Display the result.
PRINT, a
; Insert a string into a that would extend its length.
STRPUT, a, 'fun to use', 12
; Display result. Note that the inserted string was clipped so the
; length of a did not change.
PRINT, a
See Also