JOIN$ function   

Purpose

Return a string consisting of all of the strings in an array, each separated by a delimiter.

Syntax

A$ = JOIN$(array(), {delim$ | BINARY})

Remarks

JOIN$ requires a delimiter string delim$ which may be any length.

If the delimiter expression is a null (zero-length) string, no separators are inserted between the string sections.  If the delimiter expression is the 3-byte value of "," (which may be expressed in your source code as the string literal ""","""), a leading and trailing double-quote is added to each string section.  This ensures that the returned string contains standard, comma-delimited quoted fields that can be easily parsed.

The array specified by array() may be any data type.

BINARY

If the array consists of fixed size elements ( numeric, Nul-Terminated Strings, etc.), the returned string consists of an exact memory image of the array data in internal format.  If the array contains variable length data (Dynamic string, Field string), it is stored in PowerBASIC and/or Visual Basic packed string format:  If a string is shorter than 65535 bytes, it starts with a 2-byte length WORD followed by the string data.  Otherwise, it will start with a 2-byte value of 65535, followed by a DWORD indicating the string length, then finally the string data itself.

The JOIN$ function is the natural complement to the PARSE statement.

See also

BUILD$, PARSE, PARSE$, PARSECOUNT

Example

FUNCTION PBMAIN

  DIM a$(2), s1$, s2$

  a$(0) = "Hello"

  a$(1) = "Power"

  a$(2) = "BASIC"

  s1$ = JOIN$(a$(),""",""")

  s2$ = JOIN$(a$(),$SPC)

END FUNCTION

Result

s1$ contains:  "Hello","Power","BASIC"

s2$ contains:  Hello Power BASIC