Re: EOF location?



Sorry PD, CR/LF has never, and will never indicate EOF.
CR/LF indicates end-of-line (EOL)(in a text file); period.
The extra end-of-file (EOF) byte comes from MSDOS which indeed
inserted an ASCII 26 (control-z) at end of file.
Modern windows "command window" do NOT insert
this EOF anymore although they will read/interpret it.

Roger

"Pete Dashwood" <dashwood@xxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:4dtjl5F1btl54U1@xxxxxxxxxxxxxxxxx

"Rick Smith" <ricksmith@xxxxxxx> wrote in message
news:127it2ff7bacs46@xxxxxxxxxxxxxxxxxxxxx

"Pete Dashwood" <dashwood@xxxxxxxxxxxxxx> wrote in message
news:4dt42nF1brnadU1@xxxxxxxxxxxxxxxxx

"Rick Smith" <ricksmith@xxxxxxx> wrote in message
news:127ihcv1n0jub63@xxxxxxxxxxxxxxxxxxxxx

"Pete Dashwood" <dashwood@xxxxxxxxxxxxxx> wrote in message
news:4dsr45F1bi54rU1@xxxxxxxxxxxxxxxxx

"HeyBub" <heybubNOSPAM@xxxxxxxxx> wrote in message
news:127hfdman9s836f@xxxxxxxxxxxxxxxxxxxxx
Anyone know where the EOF is supposed to be located on a PC file?


Er...please sir! please sir!... at the END of the file, sir!

In other words, if Windows reports a file is, say, 100 bytes long,
is
the
EOF (X'1A') supposed to be in the 100th or 101st byte?


I did a quick experiment using a DOS box....

Here's the results... (I have added comments for those who were not
born
when the only option was a command line interface...these comments
(as
this
is a COBOL forum) are prefixed with *>

================== start of DOS box ===============

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

*> Create a simple text file with the characters 1 thru 8...

C:\Documents and Settings\dashwood>echo 12345678 > testfile.txt

*> Make sure that textfile.txt DOES contain the expected
characters...

C:\Documents and Settings\dashwood>type testfile.txt
12345678

*> Get a directory report on the file...

C:\Documents and Settings\dashwood>dir testfile.txt
Volume in drive C is PetesP4system
Volume Serial Number is D499-5305

Directory of C:\Documents and Settings\dashwood

28/05/2006 17:07 11 testfile.txt
1 File(s) 11 bytes
0 Dir(s) 10,042,187,776 bytes free

It would appear that there are three more characters than we actually
input.

Windows reports the file as 11 bytes; yet only 8 characters were
input...

Looks like a job for Hex Editor...(AXE version 3 ...)

31 32 33 34 35 36 37 38 20 0d 0a

Aha! NINE characters were input; I inadvertently entered a space...
(x20)

So, the answer to your question:

YES, the two characters which indicate EOF (in the Windows
environment)
ARE
included in the file size reported by the Operating System. Your Hex
1F
EOF
is incorrect for a text file (possibly COBOL uses a different EOF,
but
I
doubt it); it is x'0D' x'0A' and both these characters ARE INCLUDED
in
the
size reported by the OS.

So that settles it?


Try using, copy con: testfile.txt.
After typing the numbers 1 through 8, press F6 then Enter.

On Windows 98SE, I get 8 characters in the file.

Copying a console stream (or an existing file) is NOT the same thing at
all.

I agree that COPY is not the same as redirecting ECHO;
but it demonstrates that x"0D" x"0A" is not an EOF marker
--file size is.

I never intended to suggest otherwise, Rick.

I know very well that size determines the length of a file and I have
written bit stream IO routines in both x86 assembler and COBOL that
utilise this fact. Nevertheless, I wasn't 100% sure what might happen when
a line sequential file was created in this environment. The above test
seems to indicate that, when using COBOL files of type line sequential in
this environment CR LF ARE used to indicate the end of the file. The
question was whether these 'tokens' are included in the file size and my
answer is that they are.

I did NOT say that every file will include these characters, I did NOT say
that EOF is always indicated by these characters, I siimply responded to
the specific case that was presented.

I think your point is taken that there are cases where they are not used
as EOF markers or are entirely absent. I see that Richard made a clear
statement about this too.


The COPY command will only duplicate EXACTLY what it gets (this can be
modified by the various options to the command, but the default is an
exact
duplication of whatever is in operand 1). If there is no EOF marker then
it
won't be copied or created on the output. That is why I chose to use
ECHO
and redirect the output from it.

What does F6 do?

On MS-DOS 1.0 through Windows 98SE, apparently, it
insert a Ctrl+Z (or x"1A") into the stream. Only that preceeding
the Ctrl+Z is copied.

Interesting. I never knew that. Thanks.

As to it being settled, that is for HeyBub to decide. If he's using Win
98
SE he may be very interested in your results.

Or some additional experimentation might be revealing.
For example,

echo 12345678^Z > testfile.txt

where "^Z" is Ctrl+Z, creates a file with an embedded
x"1A" and terminated by x"0D" x"0A; and with a file
size of 12. [For HeyBub, the x"1A" is in the 9th, not the
12th or 13th position.]

I don't believe PowerCOBOL #INCLUDE files use this format, but, I haven't
checked and it is interesting, nonetheless.


Then

type testfile.txt > testfile2.txt

Creates a file with a file size of 8--no embedded x"1A"
and no termianting x"0D" x"0A".

The type command reads until it encounters a x"1A" or
end of file; but Windows does not insert additional characters
in the output file, as an EOF marker.


It might be best for HeyBub to simply use a hex editor on one of his
Include files and see how it is formatted.

Pete.




.



Relevant Pages

  • Re: sscanf question
    ... Input characters are taken from a supplied stdio stream (which is ... (The failure is an "input failure" if fgetc() ... would return EOF on ...
    (comp.lang.c)
  • Re: Deleting characters from opened text files using fopen
    ... You opened the file as a text stream, not as a binary stream, as ... C89 4.9.9.4 The ftell Function ... since EOF is not /, you are going to continue looping. ... A text stream is an ordered sequence of characters composed ...
    (comp.soft-sys.matlab)
  • Re: EOF location?
    ... I was confusing EOR with EOF in a line sequential file. ... EOF in modern windows systems is recognised from the file size ... *> Create a simple text file with the characters 1 thru 8... ...
    (comp.lang.cobol)
  • Re: EOF location?
    ... at the END of the file, sir! ... It would appear that there are three more characters than we actually ... Windows reports the file as 11 bytes; ... the two characters which indicate EOF (in the Windows ...
    (comp.lang.cobol)
  • Re: EOF location?
    ... *> Get a directory report on the file... ... It would appear that there are three more characters than we actually input. ... Windows reports the file as 11 bytes; yet only 8 characters were input... ... the two characters which indicate EOF ARE ...
    (comp.lang.cobol)