Strange RTE 103 problem 
Author Message
 Strange RTE 103 problem

Hello!

I've got some very strange problem with this code.
My programm stores configuration Data to EXE Files.
There are several EXE files which get configuration data appended.
First the EXE-File size is determined with GET_EXE_SIZE within
GETCONFIGEXE then it seeks to the end of the normal EXE and reads
the rest up to the fileend in a string. This works just fine
except in one case: if the EXE file can't be found, I get a

I get again RTE 103 at the next WRITE in my program.
What happens here? What goes wrong????

Thanks in advance!

Markus

Here the code:
(BP 7.0 Real Mode, both in the same UNIT)

{ermittelt die Gr"e einer EXE-Datei per EXE-Header }
{Z(nderung: 09.01.2001                               }
{IN : Name der EXE-Datei                            }
{OUT: Gr"e der EXE-Datei in Byte                   }
FUNCTION GET_EXE_SIZE(filename:STRING):LONGINT;
VAR f:FILE OF WORD;
     w,w1:WORD;
BEGIN
   {$I-}
   ASSIGN(f,filename);
   RESET(f);
   {$I+}
   IF IOresult <> 0 THEN
   BEGIN
     GET_EXE_SIZE:=0;
     EXIT; {unfein}
   END;

  {MZ Kennung ?berlesen}
   {$I-}
   READ(f,w);
   {$I+}
   IF IOresult <> 0 THEN
   BEGIN
     GET_EXE_SIZE:=0;
     EXIT; {unfein}
   END;

   {$I-}
   READ(f,w1);
   {$I+}
   IF IOresult <> 0 THEN
   BEGIN
     GET_EXE_SIZE:=0;
     EXIT; {unfein}
   END;
   {$I-}
   READ(f,w);
   {$I+}
   IF IOresult <> 0 THEN
   BEGIN
     GET_EXE_SIZE:=0;
     EXIT; {unfein}
   END;
   IF w1 <> 0 THEN w:=w-1;
   GET_EXE_SIZE:=w*512+w1;
   {$I-}
   CLOSE(f);
   {$I+}
   IF IOresult <> 0 THEN
   BEGIN
     GET_EXE_SIZE:=0;
     EXIT; {unfein}
   END;
END;

{Autor: Markus Humm                                         }
{Datum: 03.08.2001                                          }
{Z(nderung: 06.08.2001                                       }
{Zweck: liest die in einer EXE-Datei abgelegte Konfiguration}
{IN   : EXE-Dateiname, Configsstring in den gelesen wird    }
{OUT  : TRUE, falls erfolgreich, sonst FALSE                }
FUNCTION GETCONFIGEXE(exename:STRING; VAR config:STRING):BOOLEAN;
VAR datei:FILE OF BYTE;
     size :LONGINT; {EXE-Gr"e}
     i,e  :BYTE; {Laufvariable}
     ende :BOOLEAN;
BEGIN
   TEXTCOLOR(lightgray); TEXTBACKGROUND(black);
   WRITE('Lese Konfiguration aus EXE-Datei...');

   size:=GET_EXE_SIZE(exename);
   {$I-}
   ASSIGN(datei,exename);
   RESET(datei);
   {$I+}
   IF IOresult <> 0 THEN
   BEGIN
     {$I-}
     CLOSE(datei);
     {$I+}

     WRITE('[Taste]');
     readkey;

     EXIT;
   END;

   {$I-}
   SEEK(datei,size+1);
   {$I+}
   IF IOresult <> 0 THEN
   BEGIN
     {$I-}
     CLOSE(datei);
     {$I+}
     GETCONFIGEXE:=FALSE;
     WRITELN('I/O Fehler!');
     WRITE('[Taste]');
     readkey;

     EXIT;
   END;

   config:='';
   ende:=FALSE;

   REPEAT
     {$I-}
     IF EOF(datei) THEN ende:=TRUE;
     {$I+}

     IF ende = FALSE THEN
     BEGIN
       {$I-}
       READ(datei,i);
       {$I+}
       e:=IOresult;
       IF e <> 0 THEN
       BEGIN

         {$I-}
         CLOSE(datei);
         {$I+}
         GETCONFIGEXE:=FALSE;
         IF e <> 100 THEN WRITELN('I/O Fehler!')
         ELSE
           WRITELN('keine Konfiguration gefunden!');

         WRITE('[Taste]');
         readkey;

         EXIT;
       END;
       config:=config+CHR(i);
     END;
   UNTIL (ende = TRUE);

   {$I-}
   CLOSE(datei);
   {$I+}

   GETCONFIGEXE:=TRUE;
   WRITE('OK');
END;

End of posting.



Fri, 23 Jan 2004 22:02:18 GMT  
 Strange RTE 103 problem
No need to answer. The problem is already solved. It was not calling
IOresult after {$I-} thus not clearing any errorcode.

Greetings

Markus



Sat, 24 Jan 2004 15:39:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Strange RTE 103 problem

2. Problem with file access in TPW - error 103

3. Strange RTE 200? (NOT THE CRT BUG)

4. Binary Search tree runtime error 103

5. Strange problem when running a report

6. Strange new problem

7. MS SQL Server Strange Problem

8. A strange problem.

9. Strange problem with TQuery !

10. Strange problem with QRCompositereport.

11. Strange problem with TQuery

12. Strange problem with cached updates

 

 
Powered by phpBB® Forum Software