Board index » delphi » IO-Error BP7.0/DOS6.22

IO-Error BP7.0/DOS6.22

 {
  Compiler: BP 7.0, DOS 6.22

  IO-error description:
  If in a directory-list of different file-types you select
  unfortunately a text-file, then this text-file will be opened.
  After this mistake if you again try to use the IO-functions REWRITE, RESET
  for untyped files, each time a IOResult-error is reported.
  You have to exit to DOS and restart the program for error-correction.

  Is there a possibility for correction without exit the programm?
  }
  PROCEDURE DataStore_OldFile( VAR name   :  PathStr;
                               VAR d      : FILE;
                               VAR err_nr : Err_Typ);
    VAR
      f : FILE;     {untyped}
      io_Result : INTEGER;
  BEGIN
    {$IFOPT I+} {$DEFINE IPLUS} {$I-} {$ENDIF }
    ASSIGN( f, name);
    RESET(  f, 1);           { Blocksize 1}
    io_result := IOResult;
    IF io_result = 0 THEN
    BEGIN
       ....
      d := f;
    END ELSE
    BEGIN
      {ERROR-MESSAGE}
      err_nr := io_result;
      d := NIL;
    END;
    CLOSE( f);
    io_result := IOResult;
    {$IFDEF IPLUS} {$UNDEF IPLUS} {$I+} {$ENDIF}
  END;

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

 

Re:IO-Error BP7.0/DOS6.22


Quote
don...@my-dejanews.com wrote in message

<6p4ra6$hm...@nnrp1.dejanews.com>...

Quote
>  IO-error description:
>  If in a directory-list of different file-types you select
>  unfortunately a text-file, then this text-file will be opened.
>  After this mistake if you again try to use the IO-functions
REWRITE, RESET
>  for untyped files, each time a IOResult-error is reported.
>  You have to exit to DOS and restart the program for
error-correction.

>  Is there a possibility for correction without exit the programm?
>[snip code]

Not sure I understand what you mean about text files - they should
function alright as untyped files - but I notice you have {$I-}..{$I+}
around your code. If any error occurs in the bits you did not post,
IoResult will be set and this will inhibit _all_ I/O operations until
IoResult is called. In particular the Close(f); call will not work. I
notice you call IoResult after Close, to clear any error. Try calling
it _before_ Close as well.

FP

Other Threads