how to find out the actual directory?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by hkey.

Two things:

I want to get the name of the directory, from which a compiled Purebasic-Exe is started. Is there a system variable?

By clicking on the Load-Button in Purebasic Editor, I always start
in the Desktop-Directory. I then have to change to Arbeitsplatz, switch to another drive and open there the purebasic directory.
Is there any possibility to start loading directly in the purebasic workdir?

I hope, anyone can help me?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Froggerprogger.

1. I found no possibility to get the current Directory using PB-Code, but with the Win-Api. Just add the following code wherever you want.

Code: Select all

CurrentDir.s = Space(255) ;Declare the StringGetCurrentDirectory_(255, CurrentDir) ;Call WIN-API-Function, set max-length to 255 and the pointer to the varible
MessageRequester("",CurrentDir,0) ;View the result
2. Set the Sourcecode-Dir in the Preferences-Menu (Datei->Voreinstellungen :wink: to the Directory you want.

3. Feel free and eat some Kartoffeln .

Purebasic - what a nice name for a girl-friend
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Hello hkey,

Welcome to the forum ...

I use the following code to get the current directory when running a program (API based function) :

CurrentDirectory.s = Space(255)
GetCurrentDirectory_(255, @CurrentDirectory)
CurrentDirectory = CurrentDirectory + "\"

Hope this helps.

KRgds

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Hello FroggerProgger ... sorry I made a concurrent post to yours.

We have the same tips :)

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> CurrentDirectory.s = Space(255)
> GetCurrentDirectory_(255, @CurrentDirectory)
> CurrentDirectory = CurrentDirectory + "\"

You shouldn't add the trailing slash without checking for it first,
because if your exe is run from a root drive, then you'll have a
double-slash at the end, making it fail. So change it to this:

If Right(CurrentDirectory,1)"\" : CurrentDirectory + "\" : EndIf


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by hkey.

Hi Froggerprogger, fweil & PB,

thanks a lot for the fast reply!
The method to find currentdir is just, what I searched.

But changing Datei/Voreinstellungen/Sourcecodeverzeichnis :wink: doesn't help: Datei öffnen starts alsways from "Desktop"

I recently registered and downloaded Purebasic Version 2.90
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

If you have a legal registered copy of PureBasic,
you should update to v3.40 instead using v2.90.

v2.90 sounds more like the Amiga-Version, but this
API tip here wouldnt help much on Amiga. :)


See http://www.purebasic.com/download.php3 for PureBasic updates
and on the http://www.reelmediaproductions.com/pb/ for latest Editor.

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by hkey.

>If you have a legal registered copy of PureBasic,
>you should update to v3.40 instead using v2.90.

Thank you, Danilo!

I made the update and now loading files works as it should.

PS: Surely do I have a legal registered copy! I bought it via master creating's Purebasic Website. There's also a separate link to download the update, which I didn't notice. Kartoffeln on the eyes?
Post Reply