PDA

View Full Version : Usage of the JOIN$ Keyword



Michael Clease
28-05-2007, 10:14
' Usage of the JOIN$ Keyword
'
' Written by Abraxas

USES "UI"
USES "FILE"


DIM SelectedDIR AS STRING ' The directory that we want to scan
Dim TheFileList() As String ' The Filename Table
DIM FileLength() as DWORD ' The File Length Table
Dim NumberofFiles As DWORD ' The Number of files in the list
DIM n as LONG ' Loop Variable
dim sMsg as string ' Message String


SelectedDIR = Dialog_BrowseForFolder(0, "Please select a directory", "C:\", %FALSE)
NumberofFiles = DIR_ListArray(TheFileList, SelectedDIR, "*.*", %FILE_NORMAL or %FILE_ADDPATH)
'MsgBox 0, "Directory "+SelectedDIR+$CRLF+$CRLF+"FileList "+TheFilelist(1)+$CRLF+$CRLF+"Number of files "+NumberofFiles

' Fill File Length Table

redim FileLength(NumberofFiles) ' Allocate space for File Length Table
for n = 1 to NumberofFiles
FileLength(n) = File_Size (TheFileList(n)) ' MSGBOX 0, n+" "+TheFileList(n)+" "+FileLength(n)
next

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

msgbox 0, sMsg

ErosOlmi
28-05-2007, 12:59
Script changed to:

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

I will use your original to add sample to DIALOG_BrowseForFolder and DIR_ListArray keywords.

Thanks
Eros

Michael Clease
28-05-2007, 13:17
yeah thats alot better.