home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PASTUT34
/
DOSOPS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-06-17
|
2KB
|
61 lines
program dos_operations;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
{ Program to illustrate the use of DOS operations from a Pascal Program. }
{ }
{ DOSOPS.PAS R. Shaw 5.4.91 }
{ }
{________________________________________________________________________}
{$M $4000,0,0} {Sets memory allocation - stacksize, heapmin, heapmax}
{see page 272 of Programmer's Guide for syntax }
uses DOS, Crt; {Makes available the procedures and functions of Units}
var
x,y,z : integer;
dir,dir2,dir3 : string;
c : char;
begin
clrscr;
{This is a trivial background task into which DOS commands are inserted}
x := 1;
y := 3;
z := 0;
GetDir(0,dir); {I/O procedure from System unit - p131 Prog. Guide}
writeln('Start directory is ',dir);
writeln('Press any key to continue');
writeln;
c := readkey;
z := x + y;
ChDir('\'); {I/O procedure from System unit - p131 Prog. Guide}
GetDir(0,dir2);
writeln('Changed directory is ',dir2);
writeln('Press any key to continue and list all *.SYS files');
writeln;
c := readkey;
SwapVectors; {Process-handling procedure from DOS unit - p146 }
Exec(GetEnv('COMSPEC'),'/C DIR *.SYS'); {Also from DOS unit - pp146/7}
If DosError <> 0 Then
Begin
Writeln('Error loading child program COMMAND.COM');
writeln('Dos error #', DosError);
writeln('Please check your operating system files.');
End;
SwapVectors;
writeln;
ChDir(dir);
GetDir(0,dir3);
writeln('Return to start directory, ',dir3);
writeln('Press any key to continue');
writeln;
c := readkey;
z := z + 3;
writeln('The background task gives z = x + y + 3 = ',x,' + ',y,' + 3 = ',z);
writeln('Press any key to continue');
c := readkey;
end.