Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-22-2001, 03:25 AM
gman gman is offline
Junior Member
 
Join Date: Aug 2001
Posts: 4
Default I/O Error 183?

I am trying to use the following code to save items from a listview to a text file on the close of a form:


var
x: integer;
FavFile: TextFile;
fav: String;
begin
fav:=getcurrentdir()+'\config\favorites.txt';
try
AssignFile(FavFile,fav);
ReWrite(FavFile);
for x:=0 to listview1.items.count-1 do
begin
Writeln(FavFile,listview1.items[x].caption);
Flush(FavFile);
end;
finally
CloseFile(FavFile);
end;
end;


The problem is that when it actually fires up I get an I/O Error 183. Then if I try to close the program again everything works fine.

I have looked up the I/O errors but can't find error 183.

Delphi 6.0 Enterprise
Windows XP (build 2526)



Thanks
G
Reply With Quote
  #2  
Old 08-22-2001, 04:07 AM
PoseFant PoseFant is offline
Senior Member
 
Join Date: Jan 2001
Posts: 1,002
Default RE: I/O Error 183?

I exchanged you FileName syntax with my own, and disabled IO checking.

var
F : TextFile;
FileName : string;
I : Integer;
begin
FileName := ExtractFileDir(ParamStr(0)) + '\config\favorites.txt';

try
{$I-}
AssignFile(F,FileName);
ReWrite(F);

for I := 0 to ListView1.Items.Count - 1 do
begin
WriteLn(F,ListView1.Items[I].Caption);
Flush(F);
end

finally
CloseFile(F);
{$I+}
end;

end;

Regards

/Filip
Reply With Quote
  #3  
Old 08-22-2001, 04:41 AM
gman gman is offline
Junior Member
 
Join Date: Aug 2001
Posts: 4
Default RE: RE: I/O Error 183?

Thanks, that did it.

Thanks
G
Reply With Quote
  #4  
Old 08-22-2001, 05:26 AM
urgleflogue urgleflogue is offline
Senior Member
 
Join Date: Apr 2001
Posts: 123
Default RE: RE: RE: I/O Error 183?

Actually this error means that the file you're writing to already exists :
183L ERROR_ALREADY_EXISTS
and it is good idea of turning IO errors off;
although I don't know why DELPHI issuses that error when you are actually recreating the file with Rewrite ....

regards
Plamen Vassilev
ICQ : 73027127
EMail : Urgleflogue@Yahoo.com

PS. Please don't click on Accept as Answer link. I already have 3 points and I think that's enough
Reply With Quote
  #5  
Old 08-24-2001, 06:35 AM
gman gman is offline
Junior Member
 
Join Date: Aug 2001
Posts: 4
Default RE: RE: RE: I/O Error 183?

Belive it or not the error is still there. Even with I/O error checking turned off. It only happens for the first file that I try to write. The second seems to write fine. and if I say ok to the error and try again everything is fine.

Weird?!? Maybe a problem with Windows XP (aka Windows 2002). Or just something I am missing.

Cheers.
G

Thanks
G
Reply With Quote
  #6  
Old 08-24-2001, 06:43 AM
gman gman is offline
Junior Member
 
Join Date: Aug 2001
Posts: 4
Default RE: RE: RE: I/O Error 183?

STUPID STUPID STUPID....

{I+} and {I-} is not the same as {$I+} and {$I-}

Thanks for all of you help anyways.

Thanks
G
Reply With Quote
  #7  
Old 08-24-2001, 08:01 AM
PoseFant PoseFant is offline
Senior Member
 
Join Date: Jan 2001
Posts: 1,002
Default RE: RE: RE: I/O Error 183?

The $I switch directive enables or disables the automatic code generation that checks the result of a call to an I/O procedure. I/O procedures are described in the Object Pascal Language Guide. If an I/O procedure returns a nonzero I/O result when this switch is on, an EInOutError exception is raised (or the program is terminated if exception handling is not enabled). When this switch is off, you must check for I/O errors by calling IOResult.

/Filip
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 11:01 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.