strLib.setSubStr

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


strLib.setSubStr syntax diagram

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
String handling (system words)