Board index » delphi » IO-Error BP7.01 + Ex.Code

IO-Error BP7.01 + Ex.Code

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.
  (See attached program datastor.pas - Source on demand via Email )

  Is there a possibility for correction without exit the programm?
  Can this mistake also occure under other circumstances?

(**************************************************************************
 *                                                                        *
 *                                      Ragettli Informatik         ????? *
 *                                    7402 Bonaduz                        *
 * ??????????????????????????????????????????????????                     *
 *                                  PC-Systeme und Software               *
 *                                                                        *
 *                                                                        *
 *  Program Name:  DataStore.PAS                                          *
 *  Compiler:   BORLAND PASCAL 7.01                   MSDOS V6.22         *
 *              Real-Mode                             COPYRIGHT (c) 1998  *
 *************************************************************************)

 (*

***                              ***
*** Exempele-Using for test only ***
***                              ***

  Testprogram  for File-IO Errors
   - IOResult do not reset all IO-Errors!

  **** Info: My program is in directory D:\bai\io  *****

  For changing Datafile-Path change constant:
    CONST pathOfFile='D:\BAI\IO\';

 *)

PROGRAM DataStore;
    USES DOS;

  TYPE FilStr = STRING[ 12];  VAR fileNameH  :  FilStr;  { CONST
pathOfFile='D:\BAI\IO\'; {}  { CONST pathOfFile='C:\BAI\IO\'; {}  CONST
pathOfFile='D:\BAI\IO\'; {} { LOCAL Procedure
}  PROCEDURE DataStore_CreateTextFile(VAR
fNameH  : FilStr);  VAR  path  : PathStr;  fname  : PathStr;  dir  : DirStr;
name  : NameStr;  ext  : ExtStr;  dummyFile : TEXT; dummy: STRING;  io_Result
: INTEGER;

  BEGIN
    { Assign/delete Dummy-Data-File c:\dummy.prm: }
    {************ For Test only ******************}
    {$IFOPT I+} {$DEFINE IPLUS} {$I-} {$ENDIF }
    dir:= pathOfFile;
    path   := dir+fNameH;
    FSplit( path, dir, name, ext);
    path   := dir+fNameH;
    CLOSE( dummyFile);
    io_result := IOResult;

    ASSIGN( dummyFile, path);
    io_result := IOResult;
    RESET(  dummyFile);
    io_result := IOResult;

    IF io_result = 0 THEN
    BEGIN
      ERASE( dummyFile);
      io_result := IOResult;
      ASSIGN( dummyFile, path);
      io_result := IOResult;
      REWRITE(  dummyFile);
      io_result := IOResult;
    END ELSE
    BEGIN
      { ok.: filename ist neu - beibehalten }
      REWRITE( dummyFile);
      io_result := IOResult;
    END;
    dummy:= ' ';
    dummy:= '123text890';
    WRITE( dummyFile, dummy, 10);
    CLOSE(   dummyFile);
    io_result := IOResult;
    {$IFDEF IPLUS} {$UNDEF IPLUS} {$I+} {$ENDIF}
  END;
  PROCEDURE DataStore_CreateBinFile(VAR fNameH  : FilStr);
      VAR
        path    : PathStr;
        fname   : PathStr;
        dir     : DirStr;
        name    : NameStr;
        ext     : ExtStr;
        dummyFile : file; dummy: STRING;
        io_Result : INTEGER;

  BEGIN
    {************ For Test only ******************}
    {$IFOPT I+} {$DEFINE IPLUS} {$I-} {$ENDIF }
    dir:= pathOfFile;
    path   := dir+fNameH;
    FSplit( path, dir, name, ext);
    path   := dir+fNameH;
    CLOSE( dummyFile);
    io_result := IOResult;

    ASSIGN( dummyFile, path);
    io_result := IOResult;
    RESET(  dummyFile, 1);
    io_result := IOResult;

    IF io_result = 0 THEN
    BEGIN
      { file bereits vorhanden }
      ERASE( dummyFile);
      io_result := IOResult;
      ASSIGN( dummyFile, path);
      REWRITE(  dummyFile, 1);
      io_result := IOResult;
    END ELSE
    BEGIN
      { ok.: filename ist neu - beibehalten }
      REWRITE( dummyFile, 1);
      io_result := IOResult;
    END;
    dummy:= ' ';
    dummy:= '123456789012345678901234567890'+
            'AGA HUGA ! *******************'+
            '123456789012345678901234567890'+
            'TestTextAtByte 90... *********'+
            '123456789012345678901234567890';
    BlockWRITE( dummyFile, dummy, 255);
    BlockWRITE( dummyFile, dummy, 4000);
    io_result := IOResult;
    CLOSE(   dummyFile);
    io_result := IOResult;
    {$IFDEF IPLUS} {$UNDEF IPLUS} {$I+} {$ENDIF}
  END;

  PROCEDURE DataStore_WriteTextOfBinFile(VAR fNameH  : FilStr; pos:WORD);
      VAR
        path    : PathStr;
        fname   : PathStr;
        dir     : DirStr;
        name    : NameStr;
        ext     : ExtStr;
        dummyFile : file; dummy: STRING;
        io_Result : INTEGER;

  BEGIN
    {************ For Test only ******************}
    {$IFOPT I+} {$DEFINE IPLUS} {$I-} {$ENDIF }
    WRITELN( 'File:  '+fNameH);
    dir:= pathOfFile;
    path   := dir+fNameH;
    FSplit( path, dir, name, ext);
    path   := dir+fNameH;

      io_result := IOResult;
      io_result := IOResult;
      io_result := IOResult;

    CLOSE( dummyFile);
    io_result := IOResult;

    ASSIGN( dummyFile, path);
    RESET(  dummyFile, 1);
    io_result := IOResult;

  IF io_result = 0 THEN  BEGIN  { file bereits vorhanden }  WRITELN;
io_result := IOResult;  Seek(dummyFile, pos);  io_result := IOResult;  IF
io_result = 0 THEN  BEGIN  BlockREAD( dummyFile, dummy, 160);  io_result :=
IOResult;  IF io_result <> 0 THEN  WRITELN( '*** BlockRead-Error Block1 of
'+fNameH+' ***');  IF io_result = 0 THEN WRITELN( Dummy);  BlockREAD(
dummyFile, dummy, 160);  io_result := IOResult;  IF io_result <> 0 THEN
WRITELN( '*** BlockRead-Error Block2 of '+fNameH+' ***');  IF io_result = 0
THEN WRITELN( Dummy);  BlockREAD( dummyFile, dummy, 160);  io_result :=
IOResult;  IF io_result <> 0 THEN  WRITELN( '*** BlockRead-Error Block3 of
'+fNameH+' ***');  IF io_result = 0 THEN WRITELN( Dummy);  io_result :=
IOResult;  IF io_result = 0 THEN  WRITELN( '*** BlockRead-of Block1..3 seems
to be ok ***');  END ELSE  BEGIN  WRITELN;  WRITELN( 'Seek-Error of
'+fNameH);

        io_result := IOResult;
        RESET(  dummyFile);
        io_result := IOResult;
        BlockREAD( dummyFile, dummy, 10);
        io_result := IOResult;
        WRITELN( Dummy);
        io_result := IOResult;
      END;
      WRITELN;
    END ELSE
    BEGIN
      WRITELN( 'RESET-Error of '+fNameH+ ' file not found/not closed');
    END;
    CLOSE( dummyFile);
    io_result := IOResult;
    {$IFDEF IPLUS} {$UNDEF IPLUS} {$I+} {$ENDIF}
  END;
  PROCEDURE DataStore_WriteTextOfBinFileAndNotCloseFile(VAR fNameH  : FilStr;
pos:WORD);
      VAR
        path    : PathStr;
        fname   : PathStr;
        dir     : DirStr;
        name    : NameStr;
        ext     : ExtStr;
        dummyFile : file; dummy: STRING;
        io_Result : INTEGER;

  BEGIN
    {************ For Test only ******************}
    {$IFOPT I+} {$DEFINE IPLUS} {$I-} {$ENDIF }
    WRITELN( 'File:  '+fNameH);
    dir:= pathOfFile;
    path   := dir+fNameH;
    FSplit( path, dir, name, ext);
    path   := dir+fNameH;
{    CLOSE( dummyFile);
    io_result := IOResult;

Quote
}

    ASSIGN( dummyFile, path);
    RESET(  dummyFile, 1);
    io_result := IOResult;

    IF io_result = 0 THEN
    BEGIN
      { file bereits vorhanden }
      WRITELN;
      io_result := IOResult;
      Seek(dummyFile, pos);
      io_result := IOResult;
      IF io_result = 0 THEN
      BEGIN
        BlockREAD( dummyFile, dummy, 160);
        io_result := IOResult;
        IF io_result <> 0 THEN  WRITELN( '*** BlockRead-Error Block1 of
'+fNameH+' ***');
        IF io_result = 0 THEN WRITELN( Dummy);
        BlockREAD( dummyFile, dummy, 160);
        io_result := IOResult;
        IF io_result <> 0 THEN  WRITELN( '*** BlockRead-Error Block2 of
'+fNameH+' ***');
        IF io_result = 0 THEN WRITELN( Dummy);
        BlockREAD( dummyFile, dummy, 160);
        io_result := IOResult;
        IF io_result <> 0 THEN  WRITELN( '*** BlockRead-Error Block3 of
'+fNameH+' ***');
        IF io_result = 0 THEN WRITELN( Dummy);
        io_result := IOResult;
      END ELSE
      BEGIN
        WRITELN;
        WRITELN( 'Seek-Error of '+fNameH);
        io_result := IOResult;

        RESET(  dummyFile);
        io_result := IOResult;
        BlockREAD( dummyFile, dummy, 10);
        io_result := IOResult;
        WRITELN( Dummy);
        io_result := IOResult;
      END;
    END ELSE
    BEGIN
      WRITELN( 'RESET-Error of '+fNameH+ ' file not found/not closed');
    END;
    WRITELN;
{    CLOSE( dummyFile);}
    io_result := IOResult;
    {$IFDEF IPLUS} {$UNDEF IPLUS} {$I+} {$ENDIF}
  END;

  PROCEDURE DataStore_WriteTextOfTextFile(VAR fNameH  : FilStr);
      VAR
        path    : PathStr;
        fname   : PathStr;
        dir     : DirStr;
        name    : NameStr;
        ext     : ExtStr;
        dummyFile : Text; dummy: STRING[10];
        io_Result : INTEGER;

  BEGIN
    {************ For Test only ******************}
    {$IFOPT I+} {$DEFINE IPLUS} {$I-} {$ENDIF }
    WRITELN( 'File:  '+fNameH);
    dir:= pathOfFile;
    path   := dir+fNameH;
    FSplit( path, dir, name, ext);
    path   := dir+fNameH;

      io_result := IOResult;
      io_result := IOResult;
      io_result := IOResult;

    CLOSE( dummyFile);
    io_result := IOResult;

    ASSIGN( dummyFile, path);
    RESET(  dummyFile);
    io_result := IOResult;

    IF io_result = 0 THEN
    BEGIN
      { file bereits vorhanden }
      WRITELN;
      READ( dummyFile, dummy);
      io_result := IOResult;
      IF io_result <> 0
...

read more »

 

Re:IO-Error BP7.01 + Ex.Code


In article <6q9888$62...@nnrp1.dejanews.com>, Raget...@swissonline.ch
writes

Quote
>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.
>  (See attached program datastor.pas - Source on demand via Email )

>  Is there a possibility for correction without exit the programm?
>  Can this mistake also occure under other circumstances?

You must reset the IOResult variable. If you do not reset it, all
further IO does not happen.

Suggest you reset IOResult - copy it to a dummy variable or use InOutRes
:=0 then close the file.

You should be able to access other files with no problem then.

--
Pedt Scragg

Nihil illegitimi carborundum

Other Threads