setSubStr()

The system function StrLib.setSubStr replaces each character in a substring with a specified character.

  StrLib.setSubStr(
    target VagText inOut,
    targetSubstringIndex INT in,
    targetSubstringLength INT in,
    source)
target
Item that is changed.
targetSubstringIndex
Identifies the starting byte of the substring in target, given that the first byte in target has the index value of 1. This index can be an integer literal. Alternatively, this index can be an item defined as type INT or the following equivalent: type BIN with length 9 and no decimal places.
targetSubstringLength
Identifies the number of bytes in the substring that is derived from target. The length can be an integer literal. Alternatively, the length can be an item defined as type INT or the following equivalent: type BIN with length 9 and no decimal places.
source
If the target item is CHAR, MBCHAR, or HEX, the source item must be a one-byte CHAR, MBCHAR, or HEX item or a CHAR literal. If the target is a DBCHAR or UNICODE item, the source must be a single-character DBCHAR or UNICODE item.

Definition considerations

The following values are returned in SysVar.errorCode:
8
Index less than 1 or greater than string length
12
Length less than 1
20
Invalid double-byte index. Index for a DBCHAR or UNICODE string points to middle of double-byte character
24
Invalid double-byte length. Length in bytes for a DBCHAR or UNICODE string is odd (double-byte lengths must always be even)

Example

  StrLib.setSubStr(target,12,5," ");

Related reference
EGL library StrLib

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.