Navigation:  thinBasic Modules > UI (User Interface) > Common Dialogs >

Dialog_BrowseForFolder

Previous pageReturn to chapter overviewNext page

 

Description

 

Open browse for folder dialog.

 

Syntax

 

sFile = Dialog_BrowseForFolder(hwnd, Title, DefaultDirectory, ShowFiles)

 

Returns

 

String.

 

Parameters

 

Name

Type

Optional

Meaning

hwnd

Number

No

Handle of the dialog containing the control

Title

String

No

Dialog caption

DefaultDirectory

String

No

Default starting dialog directory

ShowFiles

String

No

%TRUE or %FALSE in order to show or hide files

 

Remarks

 

Restrictions

 

See also

 

Examples

 

Sample script

 

USES "UI"

 

DIM sFile   AS STRING

 

sFile = Dialog_BrowseForFolder(0, "Please select a directory", "C:\thinbasic", %FALSE)

 

MSGBOX 0, sFile

 

Thanks to Abraxas for the following script example

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)

If SelectedDIR <> "" Then

 

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

 

  ' Fill File Length Table

  ReDim FileLength(NumberofFiles) ' Allocate space for File Length Table

  For n = 1 To NumberofFiles

    FileLength(n) = File_SIZE (TheFileList(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

 

Else

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

End If

 

MSGBOX 0, sMsg