Previous Topic: INITCAPNext Topic: INVERT-SIGN


INSERT

Purpose

Returns the string that results from a specified string being inserted into a string value starting at a specified position.

Syntax

►►─── INSert ( string, insertion-string, starting-position ) ─────────────────►◄

Parameters

string

Specifies the string into which insertion-string is inserted.

String can be:

insertion-string

Specifies the string that is inserted into string.

Insertion-string can be:

starting-position

Specifies the numeric position at which insertion will begin.

Starting-position can be:

Starting-position is in a range from 1 to the length of string plus 1.

Usage

Considerations

Example

In the following example, the INSERT function is used with the SUBSTRING function to insert the first six letters of the string contained in EMP-LNAME (PIC X(20)) into the string '**', starting at position 2:

Initial value:
    EMP-LNAME: 'PARKINSON          '
Statement:
    MOVE INSERT('**',SUBS(EMP-LNAME,1,6),2) TO WK-STRING.
Returned string:
    '*PARKIN*'