Category : Pascal Source Code
Archive   : ABORTU.ZIP
Filename : TESTABRT.PAS

 
Output of file : TESTABRT.PAS contained in archive : ABORTU.ZIP
program TestAbrt;
{
Small test program to illustrate use of AbortU unit.

Note that the message you want is visible even if you re-direct output.

To try out some of the various options, you will have to compile to disk
and then execute from the command line to see the effects if standard output
is re-directed.

Note that you need to change the constant GraphPath for your directory setup
if you try the graphics mode.

Normally one would expect that a program written to use Graph would provide
its own exit handler to make sure that under all termination conditions the
CloseGraph procedure is executed (whether or not Abort was called).

ClosGrph is a tiny unit that does nothing except CloseGraph during the exit
procedure processing provided by Turbo. It could be used by you if you write
a graphics program that does all of its work in the main program so that you
never really need to write your own units.
}

Uses
AbortU,
CRT,
Graph,
ClosGrph;

const
NUL = #$00;
GraphPath = 'C:\LANG\TURBO4'; {Change this to match your directory setup}

var
ch : char;
GraphDriver : integer;
GraphMode : integer;
ErrorCode : integer;

begin
writeln ('Enter your choice of N - to see an abort during normal operation');
writeln (' G - to see an abort during graphics mode');
writeln (' S - to see an abort during standard output');
writeln (' Also try this with standard output redirected');
repeat
ch := upcase(ReadKey);
until ch in ['N','G','S'];
case ch of
'N': begin
writeln ('This is normal output using CRT.');
write ('Press any key to abort now . . ');
ch := ReadKey; if ch=NUL then ch := ReadKey;
AbortMsg ('This was an abort after normal output using CRT');
end;
'G': begin
GraphDriver := Detect;
InitGraph (GraphDriver, GraphMode, GraphPath);
ErrorCode := GraphResult;
if ErrorCode <> grOK then
AbortNumMsg (ErrorCode,'InitGraph reported this error code');
OutTextXY (0,0,'This is in graphics mode. Press any key to abort now . . ');
ch := ReadKey; if ch=NUL then ch := ReadKey;
AbortMsg ('This was an abort from graphics mode');
end;
'S': begin
writeln;
writeln ('If you want to see this work when standard output is re-directed,');
writeln ('then run the program with TESTABRT >somefile');
writeln;
assign (output,''); {change next writes to (possibly re-directed)}
rewrite (output); {standard output device}
writeln ('This is output to the standard output device');
write ('Now the program will abort . .');
AbortMsg ('This is an abort message after standard output');
end;
end;
end.


  3 Responses to “Category : Pascal Source Code
Archive   : ABORTU.ZIP
Filename : TESTABRT.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/