Hello troffers!
I want to check whether a number register contains a certain number and a
string register contains one of the predefined strings:
.ds str1 bar
.nr nr1 5
.if ((\n[nr1]=5) & ("\*[str1]"foo" : "\*[str1]"bar" : "\*[str1]"baz")) \{\
. tm okay
.\}
Invoking that with groff tells me that
test.t:3: warning: numeric expression expected (got `"')
.ds str1 bar
.nr nr1 5
.if ((\n[nr1]=5) & (0 : 1 : 0)) \{\
. tm okay
.\}
So groff expects a number returned by those string comparisons, like
"\*[str1]"foo". Therefore I could rewrite the thing using a temporary number
register:
.ds str1 bar
.nr nr1 5
.nr nr2 0
.if "\*[str1]"foo" .nr nr2 1
.if "\*[str1]"bar" .nr nr2 1
.if "\*[str1]"baz" .nr nr2 1
.if ((\n[nr1]=5) & (\n[nr2]=1)) \{\
. tm okay
.\}
.rr nr2
That works as expected, but there has to be an obvious and easy solution
without the additional number register.
Best regards
Ralph