xref: /freebsd/share/doc/usd/22.trofftut/tt07 (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
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).

@(#)tt07 8.1 (Berkeley) 6/8/93
Copyright (C) Caldera International Inc. 2001-2002. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

Redistributions of source code and documentation must retain the above
copyright notice, this list of conditions and the following
disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

All advertising materials mentioning features or use of this software
must display the following acknowledgement:

This product includes software developed or owned by Caldera
International, Inc. Neither the name of Caldera International, Inc.
nor the names of other contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.

USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

$FreeBSD$

Strings

Obviously if a paper contains a large number of occurrences of an acute accent over a letter `e', typing \eo"e\e\'" for each \*e would be a great nuisance.

Fortunately, troff provides a way in which you can store an arbitrary collection of text in a `string', and thereafter use the string name as a shorthand for its contents. Strings are one of several troff mechanisms whose judicious use lets you type a document with less effort and organize it so that extensive format changes can be made with few editing changes.

A reference to a string is replaced by whatever text the string was defined as. Strings are defined with the command .ds . The line

1 ^ds e \eo"e\e'"

2 defines the string e to have the value \eo"e\e\'"

String names may be either one or two characters long, and are referred to by \e*x for one character names or \e*(xy for two character names. Thus to get t\*el\*ephone, given the definition of the string e as above, we can say t\e*el\e*ephone.

If a string must begin with blanks, define it as

1 .ds xx " text

2 The double quote signals the beginning of the definition. There is no trailing quote; the end of the line terminates the string.

A string may actually be several lines long; if troff encounters a \e at the end of .ul any line, it is thrown away and the next line added to the current one. So you can make a long string simply by ending each line but the last with a backslash:

1 ^ds xx this \e is a very \e long string

2

Strings may be defined in terms of other strings, or even in terms of themselves; we will discuss some of these possibilities later.