Navigation:  thinBasic Modules > Core > String handling >

JOIN$

Previous pageReturn to chapter overviewNext page

 

Description

 

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

 

Syntax

 

s = JOIN$(ArrayName , Delimiter [, Format [, IndexFrom [, IndexTo]]])

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

ArrayName

Variable

No

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

Delimiter

String

No

Delimiter to use to separate each of the elements in the array.

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

 

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

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.7.0.0 Web Site: http://www.thinbasic.com