Skip to main content

Join

Returns a string created by joining a number of array elements.

Synopsis

Join(list[,delimiter])

Arguments

list A one-dimensional array containing substrings to be joined.
delimiter Optional — String character used to separate the substrings in the returned string. Usually a single character, but can be a multi-character string. If omitted, the space character (" ") is used. If delimiter is a zero-length string, all items in the list are concatenated with no delimiters.

Description

The Join function joins array elements into a string. The Split function does the opposite; it splits a string into array elements.

The array elements in list must be one-dimensional (for example, A(1), A(6), etc.). Elements are returned in ascending numeric order; elements do not have to be sequential.

Examples

The following example uses the Join function to join the substrings of MyArray. By default, it supplies blank spaces between elements.

Dim MyString, MyString2
Dim MyArray
MyArray(0) = "Mr."
MyArray(1) = "John"
MyArray(2) = "Doe"
MyArray(3) = "III"
Println Join(MyArray)   ' Returns "Mr. John Doe III".

The following example demonstrates the delimiter argument. The first Join function specifies a empty string; resulting in concatenated elements. The second Join function specifies a single-character delimiter. The third Join function specifies a multi-character delimiter.

Dim MyString, MyString2
Dim MyArray
MyArray(0) = "Mr."
MyArray(1) = "John"
MyArray(2) = "Doe"
MyArray(3) = "III"
Println Join(MyArray,"")     ' Returns "Mr.JohnDoeIII".
Println Join(MyArray,"^")    ' Returns "Mr.^John^Doe^III".
Println Join(MyArray,"^x^")  ' Returns "Mr.^x^John^x^Doe^x^III".

The following example demonstrate non-sequential array elements:

Dim MyString, MyString2
Dim MyArray
MyArray(6) = "Mr."
MyArray(4) = "John"
MyArray(3) = "Doe"
MyArray(7) = "III"
Println Join(MyArray,",")     ' Returns "Doe,John,Mr.,III".

See Also

FeedbackOpens in a new tab