Folder+Dialog

Here's code for the Select Folder Dialog function.

Please feel free to modify it. I really didn't remind myself first, how the standard Windows dialog works and looks like.

code 'Folderdialog by UncleBen dim info$(1,1) dim FolderDlg$(10) print JBFolderDialog$ end function JBFolderDialog$ level = 1 path$ = "" folder$ = "" doubleClick = 0 call ReadDrives

WindowWidth = 272 WindowHeight = 295 button #folderdlg.default, "OK", [FolderOk], UL, 30, 216, 96, 25 button #folderdlg, "Cancel", [FolderCancel], UL, 134, 216, 96, 25 listbox #folderdlg.lb, FolderDlg$(, [SelectFolder], 22, 11, 216, 160 textbox #folderdlg.tb, 22, 186, 216, 25 open "Choose Folder" for dialog_modal as #folderdlg wait [SelectFolder] if a$ = "" then wait select case case a$ = "<-" level = level-1 folder$ = word$(path$, level, "\") path$ = left$(path$, len(path$)-len(folder$)-1) folder$ = folder$; "\" doubleClick = 1 if level = 1 then call ReadDrives else call ListFolders path$ end if case doubleClick = 0 doubleClick = 1 folder$ = a$; "\" case doubleClick = 1 doubleClick = 0 if folder$ = a$+ "\" then level = level+1 path$ = path$; folder$ folder$ = "" call ListFolders path$ else doubleClick = 1 folder$ = a$; "\" end if end select wait [FolderOk] close #folderdlg exit function [FolderCancel] close #folderdlg end function sub ReadDrives while word$(Drives$, c+1) <> "" c = c+1 wend redim FolderDlg$(c) for i = 1 to c FolderDlg$(i) = word$(Drives$, i) next i end sub sub ListFolders path$ files path$, "*.*", info$( n = val(info$(0,0)) q = val(info$(0,1)) redim FolderDlg$(q+1) FolderDlg$(1) = "<-" for i = 1 to q FolderDlg$(i+1) = info$(n+i, 1) next i end sub code
 * 1) folderdlg, "trapclose [FolderCancel]"
 * 2) folderdlg.lb, "singleclickselect"
 * 1) folderdlg.lb, "selection? a$"
 * 1) folderdlg.lb, "reload"
 * 1) folderdlg.lb, "select "; left$(folder$, len(folder$)-1)
 * 1) folderdlg.tb, path$; folder$
 * 1) folderdlg.tb, "!contents? JBFolderDialog$"
 * 1) folderdlg.lb, "reload"