join()

The strLib.join()system function concatenates the given elements with the specified delimiter, returning the resulting concatenated string.

Syntax

strLib.join(
             target STRING[] | CHAR[] | DBCHAR[] | MBCHAR[] | UNICODE[] In, 
             delimiter STRING | CHAR | DBCHAR | MBCHAR | UNICODE In)
  returns (result STRING | CHAR | DBCHAR | MBCHAR | UNICODE)
target

Input can be any array that is assignment compatible with any of the above types.

delimiter

Input can be any value that is assignment compatible with any of the above types.

result

It returns a new string composed of the target elements joined together with the delimiter.

Example

  function main() 
     separator String=”/”;
     separatorChar Char(1)=”/”; 
     separatorUnicode Unicode(1)=”/”;

     animals String[] = new String[3]{“dog”, “cat”, “bird”};
     animalsChar Char(4)[] = new Char(4)[3]{“dog”, “cat”, “bird”}; 
     animalsUnicode Unicode(4)[] = new Unicode(4)[3]{“dog”, “cat”, “bird”};

     sysLib.writeStdout(strLib.join(separator, animals)); 
     sysLib.writeStdout(strLib.join(separatorChar, animalsChar)); 
     sysLib.writeStdout(strLib.join(separatorUnicode, animalsUnicode));
  end

The output is as follows:

   dog/cat/bird 
   dog /cat /bird 
   dog /cat /bird