sonny
New Member
Posts: 4
|
Post by sonny on Feb 8, 2019 17:56:29 GMT
hey all, looking for some help,
I am trying to use file dialog to select a folder, I cant see any folder dialog command in the help but through the gui editor I have added folder dialog function but I am at a loss as how to use it, I can open the file dialog but it wont let me select just a folder ?
can I use folder dialog in the same manner or is it called in a different way ?
thanks for any help
|
|
|
Post by tsh73 on Feb 8, 2019 19:54:42 GMT
Works for me it starts with drive list (c: d: etc) you double-click on a line to move deeper. Button with [ << ] rigth top moves up one level. Path to folsed is assembled in textbox below list. You can press OK/Enter to select it or add your own words (if you want to create new folder). You will get a path - if you change it, function will not check that path exist or make folder for you.
' Form created with the help of Freeform-J v.261006 ' Generated on Feb 08, 2019 at 22:49:06
dim info$(10, 10) ' <- for FolderDialog$() dim FolderList$(10) '<- for FolderDialog$()
nomainwin
WindowWidth = 296 WindowHeight = 400
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.button1, "select folder", [button1Click], UL, 14, 11, 122, 25 texteditor #main.texteditor2, 14, 41, 256, 295 menu #main, "Edit" '<--- Texteditor Menu can be moved but not removed.
open "untitled" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
wait
[quit.main] Close #main END
[button1Click] 'Perform action for the button named 'button1' 'Insert your own code here res$=FolderDialog$("Select a folder") #main.texteditor2 "folder selected" if res$="" then #main.texteditor2 "Cancel or ESC is pressed" else #main.texteditor2 res$ end if wait
'Custom functions and subs:
function FolderDialog$(caption$) 'caption$ - title of the dialog WindowWidth = 368 WindowHeight = 360 gosub [FolderDlgGetDrives] statictext #folderdlg, "Select folder:", 22, 16, 144, 20 listbox #folderdlg.list, FolderList$(, [FolderDlgSelect], 22, 41, 312, 200 button #folderdlg, "<<", [FolderDlgBack], UL, 302, 11, 32, 25 button #folderdlg.default, "&Ok", [FolderDlgOk], UL, 150, 281, 88, 25 button #folderdlg, "&Cancel", [FolderDlgCancel], UL, 246, 281, 88, 25 textbox #folderdlg.text, 22, 246, 312, 25 open caption$ for dialog_modal as #folderdlg print #folderdlg, "trapclose [FolderDlgCancel]"
print #folderdlg, "font MS_Sans_Serif 10" wait
[FolderDlgSelect] #folderdlg.list, "selection? temp$" if temp$ <> "" then level = level+1 folder$ = folder$; temp$; "\" #folderdlg.text, folder$ gosub [FolderDlgGetDir] #folderdlg.list, "reload" end if wait
[FolderDlgBack] if level > 0 then level = level-1 if level = 0 then folder$ = "" gosub [FolderDlgGetDrives] else i = len(folder$)-1 while mid$(folder$, i, 1) <> "\" and mid$(folder$, i, 1) <> "" i = i-1 wend folder$ = left$(folder$, i) gosub [FolderDlgGetDir] end if #folderdlg.text, folder$ #folderdlg.list, "reload" end if wait
[FolderDlgGetDrives] c = 1 while word$(Drives$, c) <> "" c = c+1 wend redim FolderList$(c) for i = 1 to c FolderList$(i) = word$(Drives$, i) next i return
[FolderDlgGetDir] files folder$, info$( s = val(info$(0,0)) t = val(info$(0,1)) redim FolderList$(t) for i = 1 to t FolderList$(i) = info$(i+s, 1) next i return
[FolderDlgOk] #folderdlg.text, "!contents? FolderDialog$" [FolderDlgCancel] close #folderdlg end function
|
|
sonny
New Member
Posts: 4
|
Post by sonny on Feb 9, 2019 11:48:33 GMT
Many Thanks tsh73 I was indeed calling it incorrectly res$=FolderDialog$("Select a folder") I had this line mixed up somehow FolderDialog$("Select a folder") = SourceF$ should be paying more attention but thanks again for your time and input
|
|