Board index » delphi » Really easy question (hopefully)

Really easy question (hopefully)

" <b...@selby16.freeserve.co.uk>
Subject: Really easy question (hopefully)
Date: 1999/12/11
Message-ID: <82tgsr$jn2$1@newsg2.svr.pol.co.uk>#1/1
X-Deja-AN: 559406225
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
X-Complaints-To: abuse@theplanet.net
X-Trace: newsg2.svr.pol.co.uk 944916187 20194 62.136.133.145 (11 Dec 1999 12:43:07 GMT)
Organization: Customer of Planet Online
X-MSMail-Priority: Normal
NNTP-Posting-Date: 11 Dec 1999 12:43:07 GMT
Newsgroups: comp.lang.pascal.borland

This will probably seem like a really easy question to most of you. At least
I hope it will. How can I find (and display) the current directory? i.e. In
Pascal, if I have a program open, and I open another one from another
directory, the current directory will change to that one. Therefore all
original file assignments in the original program will now point to the
wrong directory. I need to show the less able users of my program which
directory they are in. Also, it could come in handy to change this current
directory (just while running pascal, for my sanity).

--Rich

 

Re:Really easy question (hopefully)


Quote
> How can I find (and display) the current directory? i.e. In
> Pascal, if I have a program open, and I open another one from another
> directory, the current directory will change to that one. Therefore all
> original file assignments in the original program will now point to the
> wrong directory. I need to show the less able users of my program which
> directory they are in. Also, it could come in handy to change this current
> directory (just while running pascal, for my sanity).

GetDir(0,destpathstr);
SetDir...   ^[F1]
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
http://members.eunet.at/meg-glaser/    http://members.xoom.com/f_glaser/
http://www.geocities.com/~franzglaser/            http://start.at/bedarf

Re:Really easy question (hopefully)


I think, you may try next:

<begin code>
var s: string;

begin
  GetDir(0, s);
{ 0 = current drive, 1 = A:, 2 = B:, ... }
  WriteLn('Current dir is: ', s);
  ChDir('C:\');
{ change directory }
  MkDir('C:\MyTemp');
{ make directory }
  RmDir('C:\MyTemp');
{ remove directory }
end.
<end code>

Re:Really easy question (hopefully)


Ing. Franz Glaser <meg-gla...@eunet.at> wrote in message
news:38528417.ACD84D23@eunet.at...

Quote
> > How can I find (and display) the current directory? i.e. In
> > Pascal, if I have a program open, and I open another one from another
> > directory, the current directory will change to that one. Therefore all
> > original file assignments in the original program will now point to the
> > wrong directory. I need to show the less able users of my program which
> > directory they are in. Also, it could come in handy to change this
current
> > directory (just while running pascal, for my sanity).

> GetDir(0,destpathstr);
> SetDir...   ^[F1]

That answers the question that Rich asked; however, given that he wants the
information in order to generate absolute file paths he may also be
interested to know that ParamStr(0) (and fsplit) can be used to give the
path of the .EXE file being executed, in DOS versions >= 3.1. It may be
appropriate for some of his files to be in whatever the current directory
happens to be, and for others to be in the same directory as the .EXE file.

Just thought that might be useful

FP

Other Threads