Selecting directory and choosing filtered file extensions.

Moderator: Rathinagiri

Post Reply
NickSteel
Posts: 67
Joined: Mon May 27, 2013 10:44 pm

Selecting directory and choosing filtered file extensions.

Post 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.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Selecting directory and choosing filtered file extension

Post 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")

East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
NickSteel
Posts: 67
Joined: Mon May 27, 2013 10:44 pm

Re: Selecting directory and choosing filtered file extension

Post 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.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Selecting directory and choosing filtered file extension

Post by Rathinagiri »

Sorry. You have to write like this.

GetFile( { { "Harbour Program Files", "*.prg" }, { "Harbour Header Files", "*.ch" } } ,;
"Select a prg/ch file")
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
NickSteel
Posts: 67
Joined: Mon May 27, 2013 10:44 pm

Re: Selecting directory and choosing filtered file extension

Post by NickSteel »

:D

Does this return the location and file name for selecting? My program will parse the selected file into a DBF.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Selecting directory and choosing filtered file extension

Post by Rathinagiri »

Yes.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
NickSteel
Posts: 67
Joined: Mon May 27, 2013 10:44 pm

Re: Selecting directory and choosing filtered file extension

Post 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?
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Selecting directory and choosing filtered file extension

Post 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
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply