[comp.lang.pascal] file not found error

jed1@ra.MsState.Edu (Joseph E. Dunston) (02/14/91)

I have a strange problem with tp 6.0 , here is a piece of code:

Reset (datafile1);
Rewrite(datafile2);

While not eof(datafile1) do
   While not eoln(datafile2) do
     begin
       ........

We gat a file not found error if the code is left as stands.  If we comment
out the not in both of the while statements, no error.  
What gives ???????

Any suggestions welcome.

Joseph
jed1@ra.msstate.edu

John G. Spragge <SPRAGGEJ@QUCDN.QueensU.CA> (02/14/91)

Reference the person who tried to take the EOLN of a file
that was just rewritten:

When you RESET a file, the pointer is set to the beginning, like
so:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX....
^
An EOLN on this file says "get the current character in the file buffer.
If it is a 13 (carriage return) return true, otherwise, false.

When you REWRITE a file, all characters at and after the file pointer
are undefined. Since the pointer is always (barring a SEEK) at the
end of a reset file, EOF is always true, and EOLN is undefined. I
assume the support routines detected this situation and bounced you.

disclaimer: Queen's University supplies me with computer services, not
            my opinions.

John G. Spragge

ts@uwasa.fi (Timo Salmi) (02/15/91)

In article <jed1.666500501@ra> jed1@ra.MsState.Edu (Joseph E. Dunston) writes:
>I have a strange problem with tp 6.0 , here is a piece of code:
>
>Reset (datafile1);
>Rewrite(datafile2);
>
>While not eof(datafile1) do
>   While not eoln(datafile2) do
>     begin
>       ........
>
>We gat a file not found error if the code is left as stands.  If we comment
>out the not in both of the while statements, no error.  
>What gives ???????

Well, aren't eof and eoln true by default whenever we are not
specifically in the middle of an _existing_ file or a line.  And
have you first checked for the existence of datefile1.  And why an
eoln in the context of a file that is being written to? I don't
quite see the logic.  What kind of files are these supposed to be?
Text probably?  You may find your answer by considering these
points and questions. 

...................................................................
Prof. Timo Salmi        
Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

ebergman@isis.cs.du.edu (Eric Bergman-Terrell) (02/17/91)

Forgive me if I'm being obvious, but you did call the "assign" procedure
prior to the calls to reset and rewrite, right?

If not, you should (read the manual).  Having to use the assign procedure
is a nonstandard feature of Turbo...


Terrell