Solved

Appending data to file; Error I/O 32

Posted on 2000-05-17
8
828 Views
Last Modified: 2010-04-04
Hi all

Last week I was working away on Delphi problem; Data is read in... then we bit of analysis done then a log file is appended.

It worked fine last week, this week I get I/O error message 32. Frankly I am baffled...help!!!! Error report stops on x'd line.

Code Sample

var oneline     : string;
    fn          : textfile;
    x,y         : integer;

begin
   assignfile(fn,'C:\PatientLog2.txt');
   append(fn);   XXXX Error ReportXXXX

   WriteLn(fn,txtPatientNameLog.text);
   WriteLn(fn,DateToStr(Date));
   WriteLn(fn,txtMinLog.text);
   WriteLn(fn,txtMaxLog.text);
   WriteLn(fn,txtAvgLog.text);

   CloseFile(fn);
   btnSave.visible:=False;

cheers

George
0
Comment
Question by:Homer1779
8 Comments
 

Accepted Solution

by:
lizzzard earned 50 total points
ID: 2816877
Hi,

I think this ia a share-violation. Is some other program accessing this file?
Try to go to Dos or Explorer and try to rename it.. If that fails, the file is already open..
Tried to reboot yet?

Regards,
Alex
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2816915
Is there enough disk space?

Ciao, Mike
0
 
LVL 1

Author Comment

by:Homer1779
ID: 2817142
mmmmm lizzzard you may have it, will check it out and come back to you

Here only other code that access it...note lack of close!!

   assignfile(fn,'C:\PatientLog2.txt');
   reset(fn);

   while not eof(fn) do
   begin
        readln(fn,dumPatientName);
        readln(fn,dumDate);
        readln(fn,DumMin);
        readln(fn,DumMax);
        readln(fn,DumAvg);
 
        stringgrid1.cells[y,x]:=dumpatientname;
        stringgrid1.cells[y,x]:=dummin;
        stringgrid1.cells[y,x]:=dummax;
        Inc(x);Inc(y);
       
   end;
end;
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 10

Expert Comment

by:ECollin
ID: 2817407
Hi,

it is a share-violation or you're trying to a non-existing file. Your program should test these cases like that


var oneline     : string;
    fn          : textfile;
    x,y         : integer;
    OK          : Boolean;

begin
   assignfile(fn,'C:\PatientLog2.txt');
   {$I-}
   append(fn);
   {$I+}
   Ok := IOresult = 0;
   If not OK Then
      Begin
      {$I-}
      ReWrite(fn); // File creation if needed
      {$I+}
      OK := IOResult = 0;
      End;

   If OK Then
      Begin
      WriteLn(fn,txtPatientNameLog.text);
      WriteLn(fn,DateToStr(Date));  
      WriteLn(fn,txtMinLog.text);
      WriteLn(fn,txtMaxLog.text);
      WriteLn(fn,txtAvgLog.text);

      CloseFile(fn);
      End; // If Ok

   btnSave.visible:=False;

Emmanuel
0
 
LVL 1

Expert Comment

by:tomer_engel
ID: 2817648
ok, i had this problem to(even with a log file ..wierd ha?).

these are my conclutions:

a)it may be disk space.
b)it may be-trying to write/read to the file from 2 diffrent places(meaing 2 procedures trying to call to the same file)
c)try flussing the file before closing it ..

Bye Tomer  
0
 

Expert Comment

by:johnstoned
ID: 2820765
assignfile(fn,'C:\PatientLog2.txt');
   {$I-}
   append(fn);
   {$I+}
   Ok := IOresult = 0;
   If not OK Then
      Begin
      {$I-}
      ReWrite(fn); // File creation if needed
      {$I+}
      OK := IOResult = 0;
      End;

can be simplified a bit to -

AssignFile(fn, 'c:\patientLog2.txt');

if FileExists('c:\patientlog2.txt') then
  Append(fn)
else
  ReWrite(fn);

I always do that with log files, as some of my users have a bad habit of deleting logs so I can't see what they've been up to!
0
 
LVL 1

Author Comment

by:Homer1779
ID: 2825019
Thanks for the correct answer Alex and you were fast too!!!

ECollin thanks for your input..... liked what you did there but Alex answered correctly first.

johnstoned I didnt get the point of you posting half of what ECollins posted..... but god loves a chancer.... I dont!!!

thanks all


0
 

Expert Comment

by:lizzzard
ID: 2825043
I'm delighted!

Cheers,
Alex
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
proper way to parse url in delphi 2 192
Delphi TcxGrid group footer summary 3 260
Delphi: Connect to running MS Outlook 4 77
When i run adoquery my application freezes 26 165
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now