Tip: See also the IDL_String::Insert and IDL_String::Replace methods, which provide similar functionality but with an object-oriented interface.

The STRPUT procedure inserts the contents of one string into another. The source string, Source, is inserted into the destination string, Destination, starting at the given position, Position. Characters in Destination before the starting position and after the starting position plus the length of Source remain unchanged. The length of the destination string is not changed. If the insertion extends past the end of the destination, it is clipped at the end.

Examples


If the variable A contains the string “IBM is fun”, the substring “IBM” can be overwritten with the string “IDL” by entering:

STRPUT, A, 'IDL', 0

The following commands demonstrate the clipping of output that extends past the end of the destination string:

STRPUT, A, 'FUNNY', 7
PRINT, A

IDL prints:

IDL is FUN

Syntax


STRPUT, Destination, Source [, Position]

Arguments


Destination

The named string variable into which Source is inserted. Destination must be a named variable of type string. If it is an array, Source is inserted into every element of the array.

Source

A scalar string to be inserted into Destination. If this argument is not a string, it is converted using IDL’s default formatting rules.

Position

The character position at which the insertion is begun. If Position is omitted, the insertion begins at the first character (character position 0). If Position is less than zero, zero is used for the initial position.

Keywords


None.

Version History


Original

Introduced

See Also


String Operations, String Processing, STRMID, STRPOS, STRTRIM, IDL_String