fn := paramstr (1);
Assign (source, fn); Reset (source);
if IOResult<>0 then
begin writeln ('File ', fn,' doesn't exist.'); halt; end;
As the program attempts to read a file that does not exist, runtime
error occurs:
Runtime error 2 at $08066E68
$08066E68
$0805E7B4
$0806D681
I am currently using freepascal.
any help?
thanks a lot.
tony
Usually, most Pascals have error-checking turned on by default, and to be
able to use IORESULT to detect an error and handle it, you must turn off
error checking with a compile-time option.
Usually, you'd insert this just before the attempted operation, and turn it
off again after your error-handling...
{$I-} (* turn off standard I/O error handling *)
Assign (source, fn); Reset (source);
if IOResult<>0 then
begin writeln ('File ', fn,' doesn't exist.'); halt; end;
{$I+} (* turn on standard I/O error handling *)