Re: getc() ?? bug

new topic     » goto parent     » topic index » view thread      » older message » newer message

Good point, Kat. Text files are ones that are composed of zero or more
lines. A line (in DOS) is all bytes up to and including a ASCII-13 ASCII-10
combination (CRLF). In text file mode, Euphoria returns a single ASCII-10 at
end of line, thus if you try to use seek() to position yourself within the
file, you must not simply use the length of the line returned - because the
ASCII-13 has been stripped off.

But back to the original problem. If this file is truely a text file (ie.
one that is composed of lines of text) and it has embedded CTRL-Z, then open
it as a binary file and look for CRLF to mark end of lines.

As a general rule-of-thumb, I'd open all DOS files as binary unless I know
for sure that the files is *strictly* a text, line-based file.

------
Derek Parnell
Melbourne, Australia
(Vote [1] The Cheshire Cat for Internet Mascot)

----- Original Message -----
From: "Kat" <gertie at PELL.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Tuesday, November 21, 2000 5:08 AM
Subject: Re: getc() ?? bug


> On 21 Nov 2000, at 4:50, Derek Parnell wrote:
>
> > ----- Original Message -----
> > From: "Bernie" <xotron at PCOM.NET>
> > To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
> > Sent: Tuesday, November 21, 2000 3:57 AM
> > Subject: Re: getc() ?? bug
>
> <snip>
>
> > >    The reason that euphoria is wrong is because it is trying to use
the same
> > >    function to get input from the keyboard.
> >
> > Sorry, but I don't get the connection? If you type in Ctrl-Z (ASCII-26)
then
> > getc(0) will return -1. This is totally consistent, because stdin is a
DOS
> > "text" device. To get the raw data from the keyboard is to open("CON",
"rb")
> > but even this is not perfect solution, because a single Ctrl-Z on a line
is
> > interpreted as EOF.
> >
> > In summary I believe that Euphoria is correct because it is implementing
the
> > DOS standard. I think it is the DOS standard that has got it wrong. Unix
has
> >  no concept of binary/text files - they're all the same.
>
> Ok, my *one* cent worth.....
> I had this same problem in pascal yrs ago, i solved it with pascal's
> blockread() and wrote my own text parser. Then i found some bug i have
> since forgotten in the keybd read routine, and began bypassing dos for
that
> too. Then i *needed* some binary file routines for text files, and darn
it, had
> to goto assy routines for that too, to move the dos file pointer around.
Or
> was it the other way around? Well, that's why this is only one cent, Jiri.
>
> Anyhow, use dos int21, function 14 and 15 to solve most problems. Are
> these covered in dos32lib, David?
>
> Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu