PDA

View Full Version : DIALOG_OPENFILE



martin
13-09-2009, 17:21
Question:

If I use this code:



SFile=DIALOG_OPENFILE(0, "Please select one or more files", app_scriptpath,"All Files (*.*)|*.*","",%OFN_EXPLORER Or %OFN_ALLOWMULTISELECT Or %OFN_FILEMUSTEXIST Or %OFN_HIDEREADONLY Or %OFN_ENABLESIZING)



SFile returns only the path and not the selected file(s)

How can I check the selected file(s) ?

Thanks in advance!

Martin

ErosOlmi
13-09-2009, 19:08
Martin,

in case of multiple selection, Windows returns a string with files names separated by NULL chars.
So you can use something like PARSE$ or whatever to parse string checking how many files were specified.



USES "CONSOLE"
uses "UI"
dim sFile as string

SFile = DIALOG_OPENFILE(0, "Please select one or more files", _
app_scriptpath,"All Files (*.*)|*.*","", _
%OFN_EXPLORER Or %OFN_ALLOWMULTISELECT Or %OFN_FILEMUSTEXIST Or %OFN_HIDEREADONLY Or %OFN_ENABLESIZING)
dim nFiles as long
dim Counter as long
nFiles = parsecount(sFile, $NUL)

if sFile <> "" and nFiles > 1 then
printl nFiles , " files were selected:"
for Counter = 1 to nFiles
printl Counter, parse$(sFile, $NUL, Counter)
next
end if
waitkey

martin
13-09-2009, 19:11
Thank you!
I found a lot of examples on internet but i was not able to convert them to thinbasic code.