Board index » delphi » Equivalent of C ungetc()

Equivalent of C ungetc()

Does somebody know how to emulate the functionality of the Ungetc()
function in C.

Thank's
David

 

Re:Equivalent of C ungetc()


Quote
David Brillon wrote:

> Does somebody know how to emulate the functionality of the Ungetc()
> function in C.

That function is not supported in Windows. But you can use PeekMessage
to look ahead in the message queue.

M.

--
Martin Larsson, author of several unknown utilities for DOS and Windows.
mailto:martin.lars...@delfi-data.msmail.telemax.no
http://www.delfidata.no/users/~martin
X.400:G=martin;S=larsson;O=delfi-data;P=msmail;A=telemax;C=no

Re:Equivalent of C ungetc()


On Wed, 11 Sep 1996 17:58:38 GMT, "David Brillon"

Quote
<David_Bril...@uqtr.uquebec.ca> wrote:
>Does somebody know how to emulate the functionality of the Ungetc()
>function in C.

It depends on why you need ungetc. The ungetc function returns a
character to an input buffer. Delphi I/O is unbuffered. (See rant in
earlier thread...) If you are using a stream for input, you can seek
backward one byte:
    Stream.Position := Stream.Position - 1;
or
    Stream.Seek(-1, soFromCurrent);
If you are using some other file I/O mechanism, use the appropriate
seek function.

If you want to try to push back a different character from what you
read earlier, then you need to implement your own buffer. You can
derive your own stream class to implement this functionality.
--
Ray Lischner, Author of Secrets of Delphi 2 (Waite Group Press)
Tempest Software, Corvallis, Oregon, USA  http://www.tempest-sw.com

Other Threads