Setting default directory of OpenFileRequester

Just starting out? Need help? Post your questions and find answers here.
JElliott
User
User
Posts: 16
Joined: Mon Sep 03, 2007 3:44 pm
Location: Connecticut, USA

Setting default directory of OpenFileRequester

Post by JElliott »

I'm trying to figure out to change the default directory for OpenFileRequester to point to the directory of the previously opened file (assuming there has been a previously opened file). This is a fairly common behavior and saves a great deal time when loading several files. I can't figure out how to capture the path of the file when I navigate to it via OpenFileRequester. I've tried GetCurrentDirectory() but obviously it is not influenced by OpenFileRequester. I have searched and searched but not found a solution.

Any insight would be greatly appreciated thanks.

Jeff
Derek
Addict
Addict
Posts: 2356
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Have you looked at the output when you select a file?

Code: Select all

Debug OpenFileRequester("","","",0)
From the manual:
The returned 'FileName$' can be easily split into file, path and extension string with the following functions: GetFilePart(), GetPathPart() and GetExtensionPart().
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

we just had such a question in the german forum.
under windows the Open/SaveFR do automaticly open in the last used (not canceled) directory. they use both the same. but of course you must specify a filename without a path as parameter 'defaultfile$', otherwise that path is used.
or you can do it like that

Code: Select all

def_file.s = "C:\lalalalalalala"
Repeat
  file.s = OpenFileRequester("title", def_file, "*.*|*.*",0)
  If file
    def_file = file ; or 'GetPathPart(file)' if you wish
  EndIf
  Delay(500)
Until 0
JElliott
User
User
Posts: 16
Joined: Mon Sep 03, 2007 3:44 pm
Location: Connecticut, USA

Post by JElliott »

Thanks to you both Derek and #Null - exactly what I was missing - I looked at every other file related command except the obvious :oops:
Derek
Addict
Addict
Posts: 2356
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

No problem, glad I could help. :)
Post Reply