Write and Flush

This is a discussion on Write and Flush within the Pascal forums in Programming Languages category; I am wondering whether or not a call to the Flush() procedure is required after a call to Write(Output) (assuming Output is tied to the screen)? Example: begin Write(Output, 'Enter a string: '); Flush(Output); { do we need this here? } ReadLn(Input, s); end. In languages like C, this is the standard practice, but I can't find any mention about needing to do this in Pascal. I'm assuming we do because Output is still a text file......

Go Back   Application Development Forum > Programming Languages > Pascal

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 03-14-2008, 10:45 AM
Alan
Guest
 
Default Write and Flush

I am wondering whether or not a call to the Flush() procedure is
required after a call to Write(Output) (assuming Output is tied to the
screen)?

Example:

begin
Write(Output, 'Enter a string: ');
Flush(Output); { do we need this here? }
ReadLn(Input, s);
end.

In languages like C, this is the standard practice, but I can't find
any mention about needing to do this in Pascal. I'm assuming we do
because Output is still a text file...
Reply With Quote
  #2  
Old 03-14-2008, 03:54 PM
Dr J R Stockton
Guest
 
Default Re: Write and Flush

In comp.lang.pascal.borland message <fre328$u9h$1@aioe.org>, Fri, 14 Mar
2008 15:45:28, Alan <alan@local.bin> posted:
>I am wondering whether or not a call to the Flush() procedure is
>required after a call to Write(Output) (assuming Output is tied to the
>screen)?
>
>Example:
>
>begin
> Write(Output, 'Enter a string: ');
> Flush(Output); { do we need this here? }
> ReadLn(Input, s);
>end.
>
>In languages like C, this is the standard practice, but I can't find
>any mention about needing to do this in Pascal. I'm assuming we do
>because Output is still a text file...


Try it. In my BP7, I don't use Flush in such cases.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
For news:borland.*, use their server newsgroups.borland.com ; but first read
their Guidelines etc. via <URL:http://support.codegear.com/newsgroups/> ff.
Reply With Quote
  #3  
Old 03-14-2008, 04:23 PM
Marco van de Voort
Guest
 
Default Re: Write and Flush

On 2008-03-14, Alan <alan@local.bin> wrote:
> I am wondering whether or not a call to the Flush() procedure is
> required after a call to Write(Output) (assuming Output is tied to the
> screen)?
>
> Example:
>
> begin
> Write(Output, 'Enter a string: ');
> Flush(Output); { do we need this here? }
> ReadLn(Input, s);
> end.
>
> In languages like C, this is the standard practice, but I can't find
> any mention about needing to do this in Pascal. I'm assuming we do
> because Output is still a text file...


There is no difference between the languages here. The flush should be
there, but because it is probably empty for the screen in TP, omitting
doesn't happen to hurt.

But the TP textfile definition does include a flush function, and textfile
types are pluggable (by e.g. assigncrt), so an alternative implementation
that sends it to a LCD over a one wire connection might require it.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 12:18 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.