| Not sure what you mean by ``unquote''. The vbar and ampersand pair
are the begin and end quote characters:
|this is quoted.& this is not.
If a quote string is encountered during tag translation, the string
is stashed, untranslated, as the defn of the tag. If tags are contained
within the quoted string, they aren't evaluated until the parent
tag is called for.
|
| Here's a simplified form of the <HEAD1> redefinition that I'm
attempting:
<COPY_TAG>(HEAD1\xdoc_head1)
<DEFINE>(HEAD1\<EOL>
<COMMENT>( Pass 2 )<EOL>
|<EOL>
<COMMENT>( Just invoke the copied tag. )<EOL>
<xdoc_head1>($1\$2)<EOL>
<COMMENT>( Reset the requirement counter to 0. )<EOL>
<COUNTER>(xdoc_req_counter\=0)<EOL>
<COUNTER>(xdoc_head1_number\+1)<EOL>
&<EOL>
\\\\\
<COMMENT>( Pass 1 )<EOL>
|<EOL>
<COMMENT>( Just invoke the copied tag. )<EOL>
<xdoc_head1>($1\$2)<EOL>
&<EOL>
)<EOL>
As I indicated in the "\newtheorem" topic, this definition fails
during Pass 1 unless all <HEAD1> tags include a symbol name ($2).
So I tried to make the Pass 1 invocation of <xdoc_head1> include the
right number of arguments. Here's my first attempt:
<COMMENT>( Pass 1 )<EOL>
|<EOL>
<COMMENT>( Just invoke the copied tag. )<EOL>
<COMPARE>($2\<EOL>
\<xdoc_head1>($1)<EOL>
\<xdoc_head1>($1\$2)<EOL>
)<EOL>
&<EOL>
When the error messages didn't go away, I hacked in some "print"
statements (actually <TAG_DIAGNOSTIC>s) and it appeared that both
"legs" of the <COMPARE> were being evaluated/invoked.
Since that appeared to be a quoting problem, I added the "|&" quoting
characters:
<COMMENT>( Pass 1 )<EOL>
|<EOL>
<COMMENT>( Just invoke the copied tag. )<EOL>
<COMPARE>($2\<EOL>
\|<xdoc_head1>($1)&<EOL>
\|<xdoc_head1>($1\$2)&<EOL>
)<EOL>
&<EOL>
That seems to cause only the desired "leg" of the <COMPARE> to be
invoked. However, it then appears that the "$2" is passed to the
<xdoc_head1> tag as a literal, rather than having argument
substitution.
It seems that I'm in a "damned if I do and damned if I don't" situation
with respect to quoting.
There must be a way to achieve what I want because the builtin
definition of <HEAD1> probably includes similar logic.
-- Ward
P.S. A discussion of unquoting/%UNQUOTE would be far effort than it's
worth. Trust me or ask your local BLISS macro wizard.
|
| You found out about quoting args 3 and 4 to the <compare>. If you
do not quote them, they get "executed" as they are read. If you
do quote them, then only one of them gets executed, depending
on the result of the comparison.
WHen you quote them, however, you are putting a protection around
the argument references, so they do not get replaced with the arguments
to the <head1> tag. That is the damned if you do and damned if
you don't dilemma.
WHat you must do is to "unquote" each argument reference. So:
|<compare>($2\\|<foo>(&$1|)&\|<foo>(&$1|\&$2|)&)&
^------^ ^-^ ^------^ ^-^ ^-^ inner quotes
^-----------------------------------------------^ outer quote
WHat you are doing is leaving the $n argument references at the
"top-level" of quoting. That way, when the argument substitution
for the <head1> tag takes place, all the $n argument references
are not protected by any inner quoting characters, thus the
references are replaced by the corresponding arguments.
By the way, there are two ways to test if there was a second
argument. The way you have chosen tests whether the second
argument is non-blank, which is probably what you want to do.
Sometimes you want to test whether or not an argument was
supplied (even a blank or null one). In this case you'll
want to do <compare_numeric>($#\lt\2\...
bill
|