Join$

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > BuiltIn Functions > String functions >

Join$

 

Description

 

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

 

Syntax

 

On single dimension arrays:

 s = Join$(ArrayName , ElementDelimiter [, Format [, IndexFrom [, IndexTo]]])

 

On 2 dimension matrix:

 s = Join$(ArrayName , ElementDelimiter, RowDelimiter [, Format ])

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

ArrayName

Variable

No

An array variable. Array must exists and be already dimensioned.

ElementDelimiter

String

No

String delimiter to use to separate each of the elements in the array or matrix.

RowDelimiter

String

No

String delimiter to separate each of the rows of the matrix

Format

String

Yes

In case of numeric array, Format can be used to specify the format of the numeric items to be placed into the string. If you do not need it, just type an empty string: ""

IndexFrom

Number

Yes

Optional lower bound where to start to keep array data. If omitted 1 is assumed.

IndexTo

Number

Yes

Optional upper bound where to end to keep array data. If omitted current array upper bound is assumed.

 

Remarks

 

If ArrayName array is not dimensioned, no error will be generated and Join$ will return an empty string

 

Restrictions

 

See also

 

SPLIT,

 

Examples

 

Thanks to Abraxas for the following script example

' Usage of the JOIN$ Keyword

 

USES "UI"

USES "FILE"

 

Dim SelectedDIR      As String ' The directory that we want to scan

Dim TheFileList()    As String ' The Filename Table

Dim NumberOfFiles    As DWORD  ' The Number of files in the list

Dim sMsg             As String ' Message String

 

SelectedDIR   = DIALOG_BrowseForFolder(0, "Please select a directory""C:\"%False)

 

If SelectedDIR <> "" Then

  NumberOfFiles = DIR_ListArray(TheFileList, SelectedDIR, "*.*"%FILE_NORMAL Or %FILE_ADDPATH)

 

  sMsg += "Selected folder: " & SelectedDIR & $CRLF & $CRLF

  sMsg += "Number of files found: " & NumberOfFiles & $CRLF & $CRLF

  sMsg += "First 10 files are:" & $CRLF & $CRLF

  sMsg += JOIN$(TheFileList, $CRLF"", 1, 10) ' add only 10 files to list

Else

  sMsg += "No selected folder. Operation not performed."

End If

 

MSGBOX 0, sMsg

 

Example working on matrix

'---Usage of the JOIN$ Keyword with matrix

Uses "console""Math"

  

Dim MaxX    As Long   = 3

Dim MaxY    As Long   = 3

 

PrintL "Defining matrix a and b:", MaxX, "by", MaxY

 

Dim a(MaxX, MaxY) As Double

Dim b(MaxX, MaxY) As Double

 

PrintL "Filling matrix a with"Format$(MaxX * MaxY), "numbers"

 

a(1, 1) = [ 1, 0, 5,

            2, 1, 6, 

            3, 4, 0 ]

                      

PrintL "Inverting matrix a to b"

MAT b() = INV(a())   

 

PrintL              

PrintL "A is---------------------"

PrintL Join$(a, $TAB$CRLF)

                                   

PrintL                           

PrintL "B is---------------------"

PrintL Join$(b, $TAB$CRLF" 00.0;-00.0; 00.0")

 

WaitKey