Board index » delphi » Using Dos Commands Through Pascal

Using Dos Commands Through Pascal

Please could some one tell me how do I write a program or all I need
are the commands to copy, move, delete etc files on any drive by using
TP 7.0 Dos.

I want to make a kind of file manager, so I that I can copy some files
and move etc. Even run PKZIP.
I know them for qbasic like kill etc, but Could someone E-Mail me them
if they know how!!

Cheers
g.mcl...@cms.salford.ac.uk

 

Re:Using Dos Commands Through Pascal


In article <543f6r$7dc_...@cms.salford.ac.uk>,

Quote
G.McLean <MCA...@news.salford.ac.uk> wrote:

:Please could some one tell me how do I write a program or all I need
:are the commands to copy, move, delete etc files on any drive by using
:TP 7.0 Dos.

 105100 Sep 14 1996 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
 tsfaqp.zip Common Turbo Pascal Questions and Timo's answers

9. *****
 Q: How do I execute an MS-DOS command from within a TP program?

 A: The best way to answer this question is to give an example.
     {$M 2048, 0, 0}   (* <-- Important *)
     program outside;
     uses dos;
     begin
       write ('Directory call from within TP by Timo Salmi');
       SwapVectors;
       Exec (GetEnv('comspec'), '/c dir *.*');  (* Execution *)
       SwapVectors;
       (* Testing for errors is recommended *)
       if DosError <> 0 then
         writeln ('Dos error number ', DosError)
       else
         writeln ('Mission accomplished, exit code ', DosExitCode);
       (* For DosError and DosExitCode details see the TP manual *)
     end.
Alternatively, take a look at execdemo.pas from demos.arc which
should be on the disk accompanying Turbo Pascal.
   What the above Exec does is that it executes the command
processor. The /c specifies that the command interpreter is to
perform the command, and then stop (not halt).
   I have also seen it asked how one can swap the Turbo Pascal
program to the disk when shelling. It is unnecessary to program that
separately because there is an excellent program to do that for you.
It is ftp://garbo.uwasa.fi/pc/sysutil/shrom24b.zip. Also of interest
to advanced programmers even if in C
 107534 Dec 12 1992 ftp://garbo.uwasa.fi/pc/c-lang/spwno413.zip
 spwno413.zip Disk/XMS Swapping replacement for spawn(), w/C, R.Brown
  Somewhat surprisingly some users have had difficulties with
redirecting shelled output. It is straight-forward. In the above
code one would use, for example
  Exec (GetEnv('comspec'), '/c dir *.* > tmp');
--------------------------------------------------------------------

   All the best, Timo

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
mailto:t...@uwasa.fi  <URL:http://uwasa.fi/~ts>  ; FIN-65101,  Finland

Re:Using Dos Commands Through Pascal


Quote
MCA...@news.salford.ac.uk (G.McLean) wrote:
>Please could some one tell me how do I write a program or all I need
>are the commands to copy, move, delete etc files on any drive by using
>TP 7.0 Dos.

Yeah, I could...

but should I?....Hmmmm.....yeah....y not?

http://www.geocities.com/Paris/3537/pascal08.txt
http://www.geocities.com/Paris/3537/pascal10.txt

Re:Using Dos Commands Through Pascal


Two possibilities here: use the build in functions of TP to handle files
(located in the "DOS" unit, check the manual) or to call "command.com"
with the exec command, also described in the manual.

Other Threads