[comp.text] Explain Use of <Ctrl-G>s in Macros

charly@altos86.Altos.COM (Charly Rhoades) (01/05/90)

I'm hacking troff code, and I come across a number of constructions
that use <Ctrl-G> characters, such as the examples below:

	.if\w^G\\n(}Z^G .nr A 3 '
and

	.if^G\*(]S^G^G .ds ]S \s14\f3\*(}Z\fP\s0

and

	.if^G\\$1^G2^G .if !^G\\$5^G^G .ds }i\^

I suppose I'm missing something fundamental here, and I can't find any
help from the manuals (hah!).

Please enlighten me, or tell me from what source I might find
enlightenment.

Charly Rhoades                           Altos Computer Systems - San Jose, CA
                                       {amdahl|sun|pyramid|uunet}!altos!charly
------------------------------------------------------------------------------
If you know you have an unpleasant nature
and dislike people, this is no obstacle to work.                 J. G. Bennett
------------------------------------------------------------------------------

cosell@bbn.com (Bernie Cosell) (01/05/90)

charly@altos86.Altos.COM (Charly Rhoades) writes:

}I'm hacking troff code, and I come across a number of constructions
}that use <Ctrl-G> characters, such as the examples below:

Dunno about the first two, but this one:

}	.if^G\\$1^G2^G .if !^G\\$5^G^G .ds }i\^

is pretty standard usage.  The problem is that this part of troff uses
character delimited strings.  So in order to work, you have to guarantee that
the delimiter doesn't appear *in* the strings themselves.  Now, this is mostly
trivial when you are delmiting your own strings, but it becomes a bit
problematic when you're writing a macro that is going to take a string from
\\$1.  What you have to do is pick an unlikely character to use as the
in-the-macro delimiter.  We used '~' for a while, and while it was readable it
really wasn't acceptable.  control-G is a fairly conventional char to use for
that purpose.  

  /Bernie\