Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2001, 03:22 PM
ajohnstone ajohnstone is offline
Junior Member
 
Join Date: Apr 2001
Posts: 7
Default Help with runtime I/O error 6

hi there
the following code does a search on a text file to see if a batch exist. A batch can have multiple lines in the textfile. But i was testing my code and the batches numbers that really exist are 13, 14, 15, 16. But when i do the pass 16 as the batch number, i get a I/O error 6 on the 'while not EOF(F) do' Line on the very first iteration. HJCopy is just a function that exracts the batch number from the line supplied.

I would appreciate any help.

Function TFM_Price.BatchExist(File1: String; Batch: Integer):Boolean;
var F: TextFile;
Line: String;
begin
AssignFile(F, File1);
Reset(F);
while not EOF(F) do
begin
readln(F, Line);
if (StrToInt(FM_Logon.HJCopy(Line, 1)) = Batch) then
begin
CloseFile(F);
result := True;
Exit;
end
end;
CloseFile(F);
Result := False;
end;

Andrew
Reply With Quote
  #2  
Old 05-08-2001, 03:33 PM
ajohnstone ajohnstone is offline
Junior Member
 
Join Date: Apr 2001
Posts: 7
Default First problem solved - but what exactly is an I/O error 6

the error was in previous code that was not setting the filename correctly. So i assume that a I/O error 6 is that the filename isn't supplied and the EOF call fails. But hy didn't it fail on the assignfile or the reset.

Andrew
Reply With Quote
  #3  
Old 05-08-2001, 05:05 PM
Tavares Tavares is offline
Senior Member
 
Join Date: Feb 2001
Posts: 1,318
Default RE: Help with runtime I/O error 6

Go to my web site and take a look at delphi tips section.
You will find a tip about find and replace a text on TMemo.
I know it's not exactly what you want but it might give you a little ideia how to do something like that!
I hope it helps you!

Regards,
Eduardo Tavares
www.tavareswebsite.cjb.net
Reply With Quote
  #4  
Old 05-09-2001, 01:18 AM
Verence Verence is offline
Senior Member
 
Join Date: Feb 2001
Posts: 435
Default RE: Help with runtime I/O error 6

Hi Andrew!

The I/O error codes are the same as the Windows Error codes.
Lookup 'Numerical List of Error Codes' in Windows32 Help.

I/O error 6 is a 'Invalid File Handle'


HTH )
Verence
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 04:03 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.