[fpc-pascal]Changing the directory of the invoking shell
XHajT03 at mbox.vol.cz
XHajT03 at mbox.vol.cz
Sat May 18 08:47:48 CEST 2002
Date sent: Fri, 17 May 2002 09:33:10 -0700
From: Rich Pasco <pasco at acm.org>
To: fpc-pascal at deadlock.et.tudelft.nl
Subject: [fpc-pascal]Changing the directory of the invoking shell
Send reply to: fpc-pascal at deadlock.et.tudelft.nl
> Can a Free Pascal program, compiled as a Win32 console application,
> change the current directory of the invoking shell? A Borland Pascal
> program can.
.
.
BP program can do it under DOS, because both the shell and your
program operate in one environment (one address space). This isn't
true for Win32 (and other multi-tasking systems) - each program has
its own address space, and the daughter process just inherits the
settings of its parent at the moment of it's launch (but not vice
versa, of course).
> and indeed, if I compile CHD.PAS with Borland Pascal for DOS (16-bit)
> that is exacty what happens when I invoke it under the Windows 2000
> shell CMD.EXE.
>
> However, if I compile CHD.PAS under Free Pascal for Win32, then when I
> invoke it (also under CMD.EXE), it produces:
>
> C:\>CHD
> C:\>
>
> In other words, it seems that while CHD may successfully chenge the
> current directory for its own internal purposes, that change is not
> propgated back to the shell from which it was invoked, as I want. Can
> I remedy that? How?
I suspect you can't. The reason why it works for DOS programs is a
special hack for these within M$ WinXX; so it's a feature of M$
WinXX, not of either of the mentioned compilers. It _might_ work as
you expect if you compile your program for GO32v2 target (but beware:
you might encounter problems with GO32v2 programs running under
Win2000 - there should be something about this in our FAQ).
Tomas
More information about the fpc-pascal
mailing list