Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

changing the current working directory.

441 views
Skip to first unread message

Jonathan Groves

unread,
Dec 22, 2000, 11:00:36 AM12/22/00
to
I found that by using the open or save dialog boxes that the GetFileOpenName
and GetFileSaveName functions use, the current working directory changes to
whatever directory you select. This of course makes it so powerbuilder
can't find any images I use because I need to specify them by relative path
names to make my application more portable. I know there is nothing I can
do about this because it is a windows thing. Is there a way I can change
the current working directory back to the original? If not, is there a way
to find out what the current working directory is? If I could do this, I
wouldn't need to use relative path names, I can use explicit path names with
a variable on the front that contains my base path. Let me know if you have
any ideas.

Jonathan Groves


Uwe Sauerbrey

unread,
Dec 22, 2000, 11:43:35 AM12/22/00
to

Jonathan Groves wrote:

Are you talking about your development-environment? If this is an issue only
belonging to development-times then here's my tip. At this time I always open
the project-sheet of pb. One click on the search-button for the destination of
the .exe-file opens the getfilesavename()-dialog. Another click on OK makes the
thing. That might be a bit 'curious' but it works.
If you have bitmaps that you want to use within your application you should list
their filenames and path in a resource-file and advice pb to use this
resource-file (project-sheet). You won't have to administer the path for every
single file, but only the resource-file (e.g. pictures.pbr).

HTH Uwe

Jonathan Groves

unread,
Dec 22, 2000, 11:56:25 AM12/22/00
to
This seems a bit tedious. I can't believe powerbuilder deosn't have a
command to do something as simple as change the current working directory!
There has got to be an easier way to do this. I should be able to use
relative path names for bitmaps that are displayed on picture buttons,
without having a resource file.

Jonathan Groves

"Uwe Sauerbrey" <saue...@solution-execute.de> wrote in message
news:3A4384B7...@solution-execute.de...

Terry Voth

unread,
Dec 22, 2000, 1:53:55 PM12/22/00
to
Well, the first question that comes to mind is why you don't compile
these images into an executable file (EXE, PBD) so you don't have to
worry about this. I'll just leave this with you and assume you have
your reasons.

I'm going to assume you want the directory that the EXE is residing
in, not the working directory, since the user can change this to
something completely disassociated with the EXE. To get this, you need
something like:

External function prototype:
function ulong GetModuleFileNameA (unsignedlong hmod, REF string
Filename, ulong count) library "kernel32.dll"

Function:
string ls_FileName = Space (1024), ls_Dir
ulong lul_Length = 1024, lul_Module
n_cst_String lnv_String

lul_Module = Handle (GetApplication())
IF lul_Module <= 0 THEN RETURN ""
GetModuleFileNameA (lul_Module, ls_FileName, lul_Length)
ls_Dir = Left (ls_FileName, lnv_String.of_LastPos (ls_FileName, "\"))
RETURN ls_Dir // returns directory with last backslash still in place

Of course, you can customize this if you're not using PFC.

Good luck and happy whatever,

Terry [TeamSybase] and Sequel the techno-kitten

Sequel's Sandbox: http://www.techno-kitten.com
Home of PBL Peeper, a PowerBuilder Developer's Toolkit,
winner of PowerTimes 1999 "Little Helper of the Year"

Philip Salgannik

unread,
Dec 22, 2000, 1:54:11 PM12/22/00
to
It is still not clear - are you talking development or runtime?


"Jonathan Groves" <jpgr...@fergusonassoc.com> wrote in message
news:QVKL4oD...@forums.sybase.com...

Jonathan Groves

unread,
Dec 22, 2000, 2:16:39 PM12/22/00
to
I am saying that when I run my application (runtime) and I run the
GetOpenFileName function, the current working directory is changed to the
directory of the file selected in the open dialog box that appears. This is
a windows issue as it states in the help for GetOpenFileName. I am
wondering if there is a command or function or series of either that I can
run to change the current working directory back to the original. Or, is
there a way to get the current working directory and save as a string in
memory so that I won't have to use relative path names, but my code can
still be protable.

Jonathan Groves


"Philip Salgannik" <NOSPAM_p...@phtcorp.com> wrote in message
news:y9KAtqE...@forums.sybase.com...

Philip Salgannik

unread,
Dec 22, 2000, 2:36:10 PM12/22/00
to
See Terry's response. There is absolutely no reason for pathing, compile
your resources...

"Jonathan Groves" <jpgr...@fergusonassoc.com> wrote in message

news:nLNtQ3E...@forums.sybase.com...

Kevin James

unread,
Dec 27, 2000, 4:14:41 PM12/27/00
to
Use the windows API function:
FUNCTION boolean SetCurrentDirectoryA(ref string cdir) LIBRARY
"Kernel32.dll"

"Jonathan Groves" <jpgr...@fergusonassoc.com> wrote in message

news:9012rJD...@forums.sybase.com...

Jonathan Groves

unread,
Dec 27, 2000, 5:16:20 PM12/27/00
to
That's the reply I was looking for. Thank you Kevin.

Jonathan Groves


"Kevin James" <futu...@iname.com> wrote in message
news:Sjwx#uEcAH...@forums.sybase.com...

0 new messages