strLib.concatenateWithSeparator

The system function strLib.concatenateWithSeparator concatenates two strings, inserting a separator string between them. If the initial length of the target string is zero (not counting trailing blanks and nulls), the separator is omitted and the source string is copied to the target string.


strLib.concatenateWithSeparator syntax diagram

result

Numeric item that receives one of the following values (defined as type INT or the equivalent: type BIN with length 9 and no decimal places) returned by the function: :

0

Concatenated string fits in target item.

-1

Concatenated string is too long to fit in the target item and the string was truncated, as described later

target

Target item.

source

Source item or literal.

separator

Separator item or literal.

Trailing spaces and nulls are truncated from target; then, the separator string and source are appended to the truncated value. If the concatenation is longer than the target allows, truncation occurs. If the concatenation is shorter than the target allows, the concatenated value is padded with spaces.

Example

  phrase = "and";   // CHAR(7)
  or     = "or";
  result = 
    strLib.concatenateWithSeparator(phrase,or,"/");
  if (result = 0)
    print phrase;  // phrase = "and/or "
  end

Related reference
String handling (system words)