Re: problems with files

From: Bob Walkden <"Bob>
Date: Fri, 14 Dec 2001 20:49:59

Hi,

you're reading beyond the end of the file. Try this instead:

        rd.ReadInt(x);
        WHILE ~rd.rider.eof DO
                Out.Int(x,0);
                Out.Ln;
                rd.ReadInt(x);
        END;

regards,

Bob


----Original Message Follows----
From: "Juan Antonio Ortega" <amortega{([at]})nowhere.xy
To: <blackbox{([at]})nowhere.xy
Subject: problems with files
Date: Fri, 14 Dec 2001 20:32:37 +0100

In this module, I write in a file 11 numbers but, in "procedure read", I
read 12 numbers! What's wrong? I can't find the error.

MODULE K;

IMPORT Files, Stores, Out;

PROCEDURE write*;
VAR
     e: Stores.Writer;
      f: Files.File;
      i: INTEGER;
BEGIN
      f:=Files.dir.New(Files.dir.This(""), FALSE);
      e.ConnectTo(f);
      FOR i:=0 TO 10 DO
           e.WriteInt(i);
      END;
      f.Register("hola","txt", FALSE, i);
END write;

PROCEDURE read*;
VAR
      rd: Stores.Reader;
      f: Files.File;
      x, i: INTEGER;
BEGIN
      f:=Files.dir.Old(Files.dir.This(""), "hola.txt", TRUE);
      rd.ConnectTo(f); Out.Ln;
      WHILE ~rd.rider.eof DO
           rd.ReadInt(x);
           Out.Int(x,0); Out.Ln;
      END;
      f.Close;
END read;

END K.


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

--------------------------------------------

To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy
Received on Fri Dec 14 2001 - 20:49:59 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:27:46 UTC