concatenateWithSeparator()
The vgLib.concatenateWithSeparator() system
function 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. The following occurs:
- Any trailing spaces or nulls are deleted from the target value.
- The separator value is appended to the value produced during Step 1.
- The source value is appended to the value produced by the previous step
- If the concatenated output is longer than the target parameter, the output is truncated. If the output is shorter than the target parameter, the output is padded with blanks, even if the output is a number
vgLib.concatenateWithSeparator() is one of a number of functions maintained for compatibility with earlier versions. New code should use standard EGL operators for these purposes.
Syntax
vgLib.concatenateWithSeparator(
target CHAR | DBCHAR | MBCHAR | UNICODE | STRING | HEX inOut,
source CHAR | DBCHAR | MBCHAR | UNICODE | STRING | HEX in,
separator CHAR | DBCHAR | MBCHAR | UNICODE | STRING | HEX in)
returns (result INT)
- target
- A character-type variable to which the contents of source are concatenated.
- source
- Any value that is assignment compatible with STRING, which EGL concatenates to target.
- separator
- Any value that is assignment compatible with STRING, which EGL inserts between target and source.
- result
- One of the following integer values:
- -1
- Concatenated string is too long to fit in the target field. Characters other than nulls or spaces were truncated from the result.
- 0
- Concatenated string fits in the target field.
Example
The following example illustrates the use of the vgLib.concatenateWithSeparator() function:
phrase, ormeme CHAR(7);
result INT;
phrase = "and";
ormeme = "or";
result = vgLib.concatenateWithSeparator(phrase,ormeme,"/");
if (result == 0)
SysLib.writeStdout("***"+phrase+"***"); // phrase = "and/or "
end