944,098 Members | Top Members by Rank

Ad:
Nov 6th, 2009
0

runtime error as IOresult<>0

Expand Post »
ok, when the user types in a non-exist file name, the program simply shut down. i dont know what happen

procedure set_up;
begin
write('file');readln(file);
assign(f,file); reset(f);
{$I-}if IOresult<>0 then writeln('NO File....');
close(f);{$I+}
end;
....
{this is the main program}
begin
setup;
end

this proceure is called in the main program ,yet, runtime error occurs and the screen just flashes out. it works perfectly when i type in the correct filename. i need your help!!!

grace
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
amazing_grace is offline Offline
5 posts
since Aug 2009
Nov 6th, 2009
0
Re: runtime error as IOresult<>0
Hi,

You must put the IO Checking off flag before the assign statement otherwise the exception occurs before you can check it;
Reputation Points: 11
Solved Threads: 3
Newbie Poster
quaifp1 is offline Offline
10 posts
since Oct 2009
Nov 8th, 2009
0
Re: runtime error as IOresult<>0
catch the reset(filevar)
pascal Syntax (Toggle Plain Text)
  1. {$I-}
  2. reset(f);
  3. {$I+}
  4. if ioresult <> 0 then writeln('error when trying to open the file');
Reputation Points: 132
Solved Threads: 138
Posting Pro
FlamingClaw is offline Offline
559 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Haw to allow to enter number only from number 1 to 65535.
Next Thread in Pascal and Delphi Forum Timeline: KeyPress, KeyDown not triggering event





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC