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 » Sun Jun 16, 2013 4:56 pm

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: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 141 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Sun Jun 16, 2013 5:29 pm

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

Post by NickSteel » Sun Jun 16, 2013 5:49 pm

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: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 141 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Sun Jun 16, 2013 6:00 pm

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

Post by NickSteel » Sun Jun 16, 2013 6:09 pm

: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: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 141 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Sun Jun 16, 2013 6:28 pm

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

Post by NickSteel » Sun Jun 16, 2013 6:42 pm

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: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 141 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Sun Jun 16, 2013 6:59 pm

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