Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

traperrors

15 views
Skip to first unread message

dik

unread,
May 24, 2021, 12:40:47 PM5/24/21
to
hi -

in turbo pascal one traps errors like this:

{$I-}
reset(f);
errnum := ioresult;
if (errnum <> 0) then HALT(errnum);
{$I+}

in irie pascal (http://irietools.com/) one does
this:

traperrors (false);
reset(f);
errnum := getlasterror;
if (errnum <> 0) then HALT(errnum);
traperrors (true) ;

i am attempting to port irie to turbo. i cannot see
how to write a 'traperrors' procedure in turbo
pascal.

i would appreciate any help. thanks.

Stephen Mitchell

unread,
May 26, 2021, 10:23:10 AM5/26/21
to
You don't say what version of Turbo Pascal you're using, but the short answer is that I don't think it can be done, at least in a standard way (one that doesn't require knowledge of Turbo's internals). The most obvious approach, sadly, won't work:

procedure traperrors(active : boolean);
begin
if active then
{$I+}
else
{$I-};
end;

This will compile and run without bombing (at least under Turbo Pascal 5.5, which is what I tested it on), but the call to traperrors(true) won't actually turn error trapping back on. That's because the compiler directives are evaluated at compile-time, not run-time, and the last one encountered while compiling, which is {$I-} will control for the remainder of the program.

But it shouldn't be a big deal. The Irie Programmer's Manual, though it encourages the use of traperrors(), indicates that the Irie compiler will, for compatibility, accept the {$I} forms. So if you're writing code for the Irie compiler, simply go ahead and use {$I-} and {$I+} instead of traperrors, and you will be able to bring the code to Turbo without having to edit it. If you're dealing with code that already uses the traperrors procedure, however, then you'll have to make the change manually, but that should not be difficult.

Maybe someone else can come up with a better solution?

Stephen Mitchell
Alexandria, Virginia, USA

0 new messages