buffered, unbuffered

modifier

Syntax
(buffered | unbuffered) file string-expression

or

has (buffered | unbuffered)

or

with (buffered | unbuffered)


Purpose

The modifier buffered causes buffering to occur on the named stream. That is, data for that stream will be collected until the buffer is full, then sent all at once. buffered is the default setting on all operating systems for all inputs and outputs except #error.

The modifier unbuffered causes data to be written to or from an external stream without buffering. That is, text written to an unbuffered stream is immediately output.

buffered and unbuffered can be combined with text-mode or binary-mode to describe the desired I/O characteristics of a stream.

In a declaration of any of the built-in streams, #error, #process-input, #process-output, #main-input, or #main-output, the two types of modifiers must be set separately as follows:

  declare #main-output has unbuffered
  declare #main-output has text-mode

As modifiers in opening or reopening a file, bufffered or unbuffered may be set as follows:

  open foo with unbuffered as file "foo.txt"

When combining buffered or unbuffered with binary-mode or text-mode, the two types of modifiers may either be set using separate with phrases,

  open foo with unbuffered with binary-mode as file "foo.txt"
or combined using and with brackets as follows:
  open foo with (buffered and text-mode) as file "foo.txt"

As modifiers to a file name where a string expression could be used, the two types of modifiers can be set simply as follows:

  do scan unbuffered binary-mode file "scan-me.txt"

Related Syntax
Related Concepts