What is formfeed

  • Thread starter Chun-Chieh Wang
  • Start date
M

Mark A. Odell

how does the '\f' affect output?
in what situation will I use '\f' ?

If sent to a printer, it *might* eject the current page. If sent to a
terminal window, it might push the text up some number of lines. In
practice, I don't think I've ever used it. Why don't you try it and see
what it does?
 
D

Dan Pop

In said:
how does the '\f' affect output?

"Form feed" is shorthand for something like "feed a new sheet of paper
into the printer" (implicitly meaning that the current page is ejected).

Its effect on printers using continuous paper is less well defined, but
the intent is similar. Its effect on anything else is even less well
defined.
in what situation will I use '\f' ?

Seldom. Depending on the printer type and on the way you access it,
you may want to output it before closing a stream connected to the
printer. If your program doesn't talk directly to the printer, it's
probably not needed at all.

It's most useful to programs that know exactly to what kind of printer
they're talking, so they can decide when it's the right time to move to
a new page (if the decision cannot be left to the printer itself).

Another usage is in plain text files, to divide them into *logical* pages.
There is no guarantee that these logical pages will nicely map into
physical pages when the file is printed, however. When such files are
displayed on the screen, the ASCII FF character is often represented as
^L. You can type it yourself on an ASCII keyboard as CTRL-L.

Dan
 
L

Lew Pitcher

"Form feed" is shorthand for something like "feed a new sheet of paper
into the printer" (implicitly meaning that the current page is ejected).

Its effect on printers using continuous paper is less well defined, but
the intent is similar. Its effect on anything else is even less well
defined.

Cutsheet printers are a much more recent invention than the form-feed character
is. On mainframe line printers (continious paper printers), the form-feed
character typically caused the printer to advance the paper to the top of the
next page (delimited by the perforations that seperated one page from another,
and governed by a 'print control tape' or 'print control chain' or even a
"UCB"). Even on my old ASR33 printer (with pin feed), the form-feed character
caused the printer to advance to (what it considered to be) the top of the page
(in this case, governed by a metal setpost on a cam, mounted on the pinfeed
drive).

In any case, the '\f' sequencee in C does none of these things; it simply causes
the compiler to substitute the appropriate form-feed character (or character
sequence) (in the hosted characterset) into the data stream. /How/ that
form-feed character (or sequence) is interpreted is undefined to C, and could
cause the launching of an ICBM instead of the advancement of a piece of paper
(should the external environment interpret it in that manner).


--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')
 
D

Darrell Grainger

how does the '\f' affect output?
in what situation will I use '\f' ?

The '\f' character is a form feed. It moves the active position to the
start of the next logical page. If you are sending it to a cut sheet
printer it might make the printer eject the current sheet. If it is to a
continuous feed printer it might make the printer advance to the next
perforation mark on the roll. If there is no performation mark then it
will advance to whatever the printer driver detemines is the start of the
next page.

Beyond the examples given, it is really open to interpretation. I could
program my terminal display such that a form feed means clear the screen.

Obviously since it comes from the days when output went to a teletype or
printer, it really only makes sense when you are outputting to a printer.
Even then, output to a printer tends to be unportable so you wouldn't
necessarily use stdio. So, realistically, you might never use '\f'
character. Last time I used it was some 15 or 20 years ago.
 
M

Mark McIntyre

If sent to a printer, it *might* eject the current page. If sent to a
terminal window, it might push the text up some number of lines.

and it might also print either a little arrow with an f next to it, or
a looking-glass (windows apps do both of these, when the mood takes
them).

All of these are possible, because the interpretation of escape
sequences is implementation defined.
 
H

Herbert Rosenau

how does the '\f' affect output?
in what situation will I use '\f' ?
Every time you knows that you doesn't print to a real endless stream
of bytes, but to a (series) of forms. '\f' tells the driver that the
current form is finished and that another should be made ready. If you
prints to a screen, the scrren gets cleard, if you prints to a card
puncher the current card gets released and the next one positioned so
that the next print will start at column one, if you prints to a
printer the current page gets removed from the printer and the next
one gets inserted so that the first logical printable line gets
presented, if you prints to a file that is formed as something a
printer driver (e.g. postcript or hpgl or something else) will know
what it has to do when it gets the page presented to put it out to its
device.

To make it short, on text streams (binary streams will always ignore
any special meaning):
- '\n' closes a line
- '\f' closes a page
- '\t' prints a tab wide spaces (whereas the definition of the tab
depends on the driver attached to the stream.)
- '\b' lets the logical cursor go a char backwards
whereas this cursor may be a the cursor on screen, the printhead,
a pinter inside the print buffer on the device or the driver....
- '\a' may ring a bell, a siren, or another device that
does require the attention of the operator or even does nothing when
no device that can be activated on that signal gets activated.
On a PC it will give traditionally a signal to the speaker or
play a wave file through the soudcard - or even do nothing or
something else.
This depends completely on the driver that receives the stream.

There are more special defined charachters to modify the stream in
shorthand or with special meaning.

So a C programm has many possibilities to modify the visible result
often without knowing which device is attached to it.

--
Tschau/Bye

Herbert Rosenau
http://www.pc-rosenau.de eComStation Reseller in Germany
eCS 1.1 GA englisch wird jetzt ausgeliefert
 
M

Mike Wahler

Chun-Chieh Wang said:
how does the '\f' affect output?

That depends upon the target device.
in what situation will I use '\f' ?

When the device to which you have a stream
attached has assigned a particular meaning
to '\f' which you find useful. Example:
some printers will eject a page when receiving
a '\f' character.

Depending upon the applications you write, you
might indeed never use '\f'. It's been a long
while since I've used it myself.

-Mike
 
M

Micah Cowan

In any case, the '\f' sequencee in C does none of these things; it simply causes
the compiler to substitute the appropriate form-feed character (or character
sequence) (in the hosted characterset) into the data stream. /How/ that
form-feed character (or sequence) is interpreted is undefined to C, and could
cause the launching of an ICBM instead of the advancement of a piece of paper
(should the external environment interpret it in that manner).

As could any character, including plain old ordinary printable
characters, etc., as the interpretation of a character by the host
environment is completely outside of the scope of the C language (and
its standard). However, the standard does put forth the *intended*
interpretation for "\f", so I think we're pretty safe for that :)

-Micah
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top