tags:

views:

595

answers:

2

I was running an application in Delphi4 and then I got the error

Exception EInoutError in the Data Module at 000C50BC I/O Error 103

I basically ...could not make head or tails of it....i was not able to open/run the .exe file through the Delphi GUI but was able to run it.

Kindly help.

    {
****************************************************************************
* The WritelnXx routines are used to send status information to standard
* output.
****************************************************************************
}
procedure WritelnIn(const s: string; level: integer = 0); overload;
  var
    i: Integer;
  begin
    for i := 1 to level do Write('    ');
    **Writeln(s);**
  end;

procedure WritelnIn(const s: string; e: Exception; level: integer = 0); overload;
  begin
    WritelnIn(s + '[' + e.message + ']', level);
  end;

procedure WritelnAb(const s: string; level: integer = 0); overload;
  begin
    WritelnIn(s, level);
    Abort;
  end;

procedure WritelnAb(const s: string; e: Exception; level: integer = 0); overload;
  begin
    WritelnIn(s, e, level);
    Abort;
  end;

The error is showing at " Writeln(s);"...in the same file DataMagr.dpr

+5  A: 

I/O Error 103 is File Not Open. According to the Delphi 7 help file:

"Reported by CloseFile, Read/Write, Seek, Eof, FilePos, FileSize, Flush, BlockRead, or BlockWrite if the file is not open."

Also, what does this have to do with your other question that you've provided a link to above?

Ken White
Thnaks Ken, for the reply.I am using Delphi -4.How do I rectify the error , is this error an critical one?I got the above errror when I made the additions as expalined in the Question, the link provided.
vas
Yes, the error is critical. Something that is supposed to be working with the file is failing because the file isn't open. To fix it, you'll need to look at the datamodule for use of any of the functions/procedures I listed above, and figure out why the file isn't open when they're called.
Ken White
. i checked the list of files in the Proj.dpr files and all the files were present, as per the previous Proj.dpr that did not throw an error.in fact as the excmple the in the link i provided is right in the "Proj.dpr", and i have changed it ....so i will check the changes i made.
vas
@vas: No, you misread what I wrote. You need to look at the **code** in the datamodule for the functions/procedures I listed above, if the error is coming from the datamodule. It has nothing to do with the .DPR file; it's a runtime error that comes from running **code**.
Ken White
ok i get the point now.I will do the same
vas
103 has been file not open since long before Delphi existed (most of the runtime error codes came from Turbo Pascal.) The Delphi 7 description is fine for Delphi 4. It's referring to the standard output file--I've never investigated where that might point in a GUI application but I see no logical meaning for it. Is this routine even supposed to be used other than in console mode???
Loren Pechtel
@Loren: No, it isn't (as Allen Bauer pointed out). vas needs to change his code to not use stdout, or change it to a console app so that stdout exists.
Ken White
+4  A: 

Make sure the application is compiled as a console application {$APPTYPE CONSOLE} since calling Write or Writeln to write to stdout and the console is not opened, it will fail like this. Using {$APPTYPE CONSOLE} will have the side-effect of either using the existing console from which the application is started, or create a new console window to use.

Another solution is to redirect the Output standard text file (stdout) to a file. Try this:

AssignFile(Output, 'logfile.log');
Rewrite(Output);

Now all regular "Write" or "Writeln" calls will go to "logfile.log" file.

Allen Bauer
i did add "AssignFile(Output, 'logfile.log');Rewrite(Output);" at the place where the cursor was pointing an error and it did run but the Log file is empty.
vas
Did you check the file while it was running? Could be due to buffering, so the data may not be fully written until the app terminates or the output file is closed.
Allen Bauer
i checked it after the file stopped running and still I am getting empty log file. i am sorry but how to decipher the error step by step...should i check all the files that are being called in the .dpr file?
vas