Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default path for getfile() based on previously found location

Status
Not open for further replies.

jworley

Programmer
Jun 19, 2000
36
GB
Hi,

I'm using getfile() to locate a file that the user wishes to import/export. In use, the first time the user browses to a particular location, the path seems to stay in memory until the program is terminated.

I'd like to be able to store the path that the user first browsed to, and start from that location by default, the next time the routine is used. Any ideas anyone?

My code to call getfile()

filename = getfile( "Comma Delimited Files (*.csv):csv", "CSV File", "Export", 0, "Export Record " + str(record_id))

Jim Worley
jim@aits-uk.net
 
jworley

Store the path in a custom class' property, or the form's property.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks Mike,

I'd like to use the path next time the program is used, this would mean that I would have to store it in a database field, and then get getfile() to look at the store path next time the program runs.

Is this possible?

Jim Worley
jim@aits-uk.net
 
Hi
Create a form property or a variable.. let us say.. myPath or make it a global variable myPath


LOCAL lcMyDefa, lcFile
lcMyDefa = SET("DEFA")

IF EMPTY(ThisForm.myPath)
ThisForm.myPath = lcMyDefa
ENDIF

lcFile = GETFILE(ADDBS(ThisForm.myPath)+"*."+.....all your extensions)

** Saves and sets back the old defa
ThisForm.myPath = JUSTPATH(lcFile)
SET DEFA TO ADDBS(lcMyDefa)

:)

ramani :)
(Subramanian.G)
 
jworley

FAQ184-3106 How can I select multiple files from Windows

uses the Windows Common Dialog opposed to GetFile().

It has a property .cInitialDirectory which would give you what you are seeking.

You can store the path in a USER.dbf and in the .Init() event of the class, put

THISFORM.cusCommonDialog.cInitialDirectory = ALLT(USER.dialogpath)


Every time you complete the file find routine :-

REPL USER.dialogpath WITH THISFORM.cusCommonDialog.cFilePath IN USER


FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Jim,

Another approach would be to SET DEFAULT to the appropriate path just before you call GETFILE(), like so:

lcOldDefault = SYS(5) + SYS(2003)
SET DEFAULT TO C:\MyNewDefault
? GETFILE()
SET DEFAULT TO (lcOldDefault)

Would that work for you?

Mike


Mike Lewis
Edinburgh, Scotland
 
jworley,

You've pretty much answered this question yourself. When the user selects a file then getfile() returns the fullpath for that file and you can use Justpath() to put the location in a table's field and then the next time you issue getfile() just make sure to use the path saved in that field for the default path. Pretty straight-forward really.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top