Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   What is formfeed (http://www.velocityreviews.com/forums/t313977-what-is-formfeed.html)

Chun-Chieh Wang 07-03-2003 12:44 PM

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

--
黃子嘉論數學家:

「數學家一生只搞兩樣東西:不是搞數學就是搞女人。
但是我不是數學家…」


Mark A. Odell 07-03-2003 12:52 PM

Re: What is formfeed
 
Chun-Chieh Wang <shaka@es01.adm.nctu.edu.tw> wrote in
news:be18fd$2mti$1@netnews.csie.NCTU.edu.tw:

> 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?

--
- Mark ->
--

Dan Pop 07-03-2003 02:14 PM

Re: What is formfeed
 
In <be18fd$2mti$1@netnews.csie.NCTU.edu.tw> Chun-Chieh Wang <shaka@es01.adm.nctu.edu.tw> writes:

>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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de

Lew Pitcher 07-03-2003 02:59 PM

Re: What is formfeed
 
On 3 Jul 2003 14:14:30 GMT, Dan.Pop@cern.ch (Dan Pop) wrote:

>In <be18fd$2mti$1@netnews.csie.NCTU.edu.tw> Chun-Chieh Wang <shaka@es01.adm.nctu.edu.tw> writes:
>
>>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.


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')

Darrell Grainger 07-03-2003 05:02 PM

Re: What is formfeed
 
On Thu, 3 Jul 2003, Chun-Chieh Wang wrote:

> 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.

--
main(){int j=1234;char t[]=":@abcdefghijklmnopqrstuvwxyz.\n",*i=
"iqgbgxmdbjlgdv.lksrqek.n";char *strchr(const char *,int);while(
*i){j+=strchr(t,*i++)-t;j%=sizeof t-1;putchar(t[j]);} return 0;}


Mark McIntyre 07-03-2003 10:21 PM

Re: What is formfeed
 
On 3 Jul 2003 12:52:27 GMT, in comp.lang.c , "Mark A. Odell"
<nospam@embeddedfw.com> wrote:

>Chun-Chieh Wang <shaka@es01.adm.nctu.edu.tw> wrote in
>news:be18fd$2mti$1@netnews.csie.NCTU.edu.tw:
>
>> 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.


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.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

Herbert Rosenau 07-04-2003 07:29 AM

Re: What is formfeed
 
On Thu, 3 Jul 2003 12:44:29 UTC, Chun-Chieh Wang
<shaka@es01.adm.nctu.edu.tw> wrote:

> 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

Mike Wahler 07-04-2003 06:39 PM

Re: What is formfeed
 

Chun-Chieh Wang <shaka@es01.adm.nctu.edu.tw> wrote in message
news:be18fd$2mti$1@netnews.csie.NCTU.edu.tw...
> 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





Micah Cowan 07-05-2003 12:06 AM

Re: What is formfeed
 
Lew.Pitcher@td.com (Lew Pitcher) writes:

> 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


All times are GMT. The time now is 11:53 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.