diff options
author | Greg Lehey <grog@FreeBSD.org> | 2002-05-19 03:33:24 +0000 |
---|---|---|
committer | Greg Lehey <grog@FreeBSD.org> | 2002-05-19 03:33:24 +0000 |
commit | fa3336171c5cd78f4b3e882b87d5adff825311e2 (patch) | |
tree | b2ebdb16dfa958a555efc026304a5f6ff4a8c9fb /share/doc/usd/22.trofftut/tt12 | |
parent | 68e7a217f8019b955f87547f218e95ab237597af (diff) |
Initial checkin: 4.4BSD version. These files need to be updated with
current license information and adapted to the FreeBSD build
environment before they will build.
Approved by: David Taylor <davidt@caldera.com>
Notes
Notes:
svn path=/head/; revision=96896
Diffstat (limited to 'share/doc/usd/22.trofftut/tt12')
-rw-r--r-- | share/doc/usd/22.trofftut/tt12 | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/share/doc/usd/22.trofftut/tt12 b/share/doc/usd/22.trofftut/tt12 new file mode 100644 index 000000000000..cbd6cd456573 --- /dev/null +++ b/share/doc/usd/22.trofftut/tt12 @@ -0,0 +1,128 @@ +.\" This module is believed to contain source code proprietary to AT&T. +.\" Use and redistribution is subject to the Berkeley Software License +.\" Agreement and your Software Agreement with AT&T (Western Electric). +.\" +.\" @(#)tt12 8.1 (Berkeley) 6/8/93 +.\" +.\" $FreeBSD$ +.NH +Conditionals +.PP +Suppose we want the +.BD .SH +macro to leave two extra inches of space just before section 1, +but nowhere else. +The cleanest way to do that is to test inside the +.BD .SH +macro +whether +the section number is 1, +and add some space if it is. +The +.BD .if +command provides the conditional test +that we can add +just before the heading line is output: +.P1 4 +^if \e\en(SH=1 ^sp 2i \e" first section only +.P2 +.PP +The condition after the +.BD .if +can be any arithmetic or logical expression. +If the condition is logically true, or arithmetically greater than zero, +the rest of the line is treated as if +it were text _ +here a command. +If the condition is false, or zero or negative, +the rest of the line is skipped. +.PP +It is possible to do more than one command if a condition is true. +Suppose several operations are to be done before section 1. +One possibility is to define a macro +.BD .S1 +and invoke it +if we are about to do section 1 +(as determined by an +.BD .if ). +.P1 +^de S1 +--- processing for section 1 --- +^^ +^de SH +^^^ +^if \e\en(SH=1 ^S1 +^^^ +^^ +.P2 +.PP +An alternate way is to use the +extended form of the +.BD .if , +like this: +.P1 +^if \e\en(SH=1 \e{--- processing +for section 1 ----\e} +.P2 +The braces +.BD \e{ +and +.BD \e} +must occur in the positions shown +or you will get unexpected extra lines in your output. +.UL troff +also provides +an `if-else' construction, +which we will not go into here. +.PP +A condition can be negated by preceding it with +.BD ! ; +we get the same effect as above (but less clearly) by using +.P1 +^if !\e\en(SH>1 ^S1 +.P2 +.PP +There are a handful of +other conditions that can be tested with +.BD .if . +For example, is the current page even or odd? +.P1 +^if o ^tl 'odd page title''- % -' +^if e ^tl '- % -''even page title' +.P2 +gives facing pages different titles and page numbers on the +outside edge when used inside an appropriate new page macro. +.PP +Two other conditions +are +.BD t +and +.BD n , +which tell you whether the formatter is +.UL troff +or +.UL nroff . +.P1 +^if t troff stuff ... +^if n nroff stuff ... +.P2 +.PP +Finally, string comparisons may be made in an +.BD .if : +.P1 +^if 'string1'string2' stuff +.P2 +does `stuff' if +.ul +string1 +is the same as +.ul +string2. +The character separating the strings can be anything +reasonable that is +not contained in either string. +The strings themselves can reference strings with +.BD \e* , +arguments with +.BD \e$ , +and so on. |