[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] Combining logical operators and conditions
From: |
Ralph Graulich |
Subject: |
[Groff] Combining logical operators and conditions |
Date: |
Fri, 28 Jan 2011 01:52:31 +0100 |
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
- [Groff] Combining logical operators and conditions,
Ralph Graulich <=