Page 1 of 1
Selecting directory and choosing filtered file extensions.
Posted: Sun Jun 16, 2013 4:56 pm
by NickSteel
I need to start with a windows directory tree, select a directory and select a
specified file extension if it exists.
I'm sure there's a sample for this, but I cannot find it.
Re: Selecting directory and choosing filtered file extension
Posted: Sun Jun 16, 2013 5:29 pm
by Rathinagiri
You have to use GetFile() function.
Syntax of GetFile()
Code: Select all
GetFile ( acFilter , cTitle , cDefaultPath , lMultiSelect , lNoChangeDir ) -->SelectedFileName(s)
If <lMultiSelect> option is used, a character array containing selected
(maximun number of selected files returned is 63).
Code: Select all
eg.: GetFile( { { "*.prg", "Harbour Program Files" }, { "*.ch", "Harbour Header Files" } } ,;
"Select a prg/ch file")
Re: Selecting directory and choosing filtered file extension
Posted: Sun Jun 16, 2013 5:49 pm
by NickSteel
GetFile( { { "*.prg", "Harbour Program Files" }, { "*.ch", "Harbour Header Files" } } ,;
"Select a prg/ch file")
Opens the directory screen and allows changing directories, but does not list any *.prg files in directories where they exist.
Pardon my ignorance.
Re: Selecting directory and choosing filtered file extension
Posted: Sun Jun 16, 2013 6:00 pm
by Rathinagiri
Sorry. You have to write like this.
GetFile( { { "Harbour Program Files", "*.prg" }, { "Harbour Header Files", "*.ch" } } ,;
"Select a prg/ch file")
Re: Selecting directory and choosing filtered file extension
Posted: Sun Jun 16, 2013 6:09 pm
by NickSteel
Does this return the location and file name for selecting? My program will parse the selected file into a DBF.
Re: Selecting directory and choosing filtered file extension
Posted: Sun Jun 16, 2013 6:28 pm
by Rathinagiri
Yes.
Re: Selecting directory and choosing filtered file extension
Posted: Sun Jun 16, 2013 6:42 pm
by NickSteel
If I use:
tempx = GetFile( { { "Harbour Program Files", "*.prg" }, { "Harbour Header Files", "*.ch" } } ,;
"Select a prg/ch file")
and
MsgInfo (tempx)
I get blank message box. How is best way to "see" the info in tempx?
Re: Selecting directory and choosing filtered file extension
Posted: Sun Jun 16, 2013 6:59 pm
by Rathinagiri
Did you click cancel in the GetFile dialog?
It returns the selected filename along with the path.
Please try this sample...
Code: Select all
#include <hmg.ch>
Function Main
cFileName := GetFile( { { "Harbour Program Files", "*.prg" }, { "Harbour Header Files", "*.ch" } } ,;
"Select a prg/ch file")
MsgInfo ( cFileName )
Return