Join Method
The Join method concatenates an array of StringObjects into a StringObject, replaces the original value, then returns that updated StringObject. If a delimiter is supplied, it is inserted between each StringObject array element.
This method has the following syntax:
StringObject = StringObject.Join(strings = array of StringObject
[, delimiter = varchar(256)])
This method has the following parameters:
strings
(Required) Specifies the array of StringObjects that are to be concatenated
delimiter
Specifies a string that is to be inserted between each StringObject in the array during the join
Any existing contents of the host StringObject are intentionally lost (unlike ConcatString (see
ConcatString Method). However, if the host is an element of the array, its contents will be preserved and included in the join.
If the required strings parameter is not passed, the StringObject remains unchanged.
This method returns a StringObject (the one on which the method call was made).
An example of Join() usage:
initialize()=
declare
soarray = array of stringobject;
so = stringobject;
idx = integer not null default 1;
enddeclare
{
// Empty StringObject array
so = so.Join(strings = soarray);
curframe.trace(text = 'Join Empty StringObject array: ' + so.value);
// StringObject array with 3 records.
soarray[1].value = 'Line1_';
soarray[2].value = 'Line2_';
soarray[3].value = 'Line3_';
so = so.Join(strings = soarray);
curframe.trace( text = 'Join StringObject array with 3 records: ' + so.value);
// StringObject array with 3 records, inserting a delimiter($)
so = so.Join(strings = soarray, delimiter = '$');
curframe.trace(text = 'Join StringObject array with 3 records, inserting a delimiter($): ' + so.value
}
Produces the following in the Trace file:
Join Empty StringObject array:
Join StringObject array with 3 records: Line1_Line2_Line3_
Join StringObject array with 3 records, inserting a delimiter($): Line1_$Line2_$Line3_
Last modified date: 12/20/2023