[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [groff] Changing A Defined String
From: |
Tadziu Hoffmann |
Subject: |
Re: [groff] Changing A Defined String |
Date: |
Sat, 27 Jan 2018 03:15:49 +0100 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
> I created the ds FIND*COMMA from DATE*FULL and used .substring
> to find the pairing ``, ''. I created the ds DATE*SHORT and
> subjected it to the successful .substring request.
> The only thing worth mentioning is that FIND*COMMA must be
> redefined at the beginning of each nested conditional, having
> been irrevocably altered during the previous conditional.
Would you mind posting your solution? I'm curious as to how
you coded it.
Anyhow, in an earlier message I said I didn't think it was
possible to do all the required processing inside a single
string invocation. It turns out I was wrong, it's entirely
possible. Here is a sample solution, which strips off
everything up to the first comma, irrespective of context:
.\" ----------------------------------------------------------------
.de DATE*SHORT
\c
.ds AA \\*[DATE*FULL]
.ds BB \\*[DATE*FULL]
.YY
.AA
..
.de YY
.ds CC \\*(BB
.length BB \\*(BB
.if \\n(BB>1 .substring BB 1
.substring CC 0 0
.if '\\*(CC',' .ZZ
.if \\n(BB>1 .YY
..
.de ZZ
.if \\n(BB>1 .ds AA \\*(BB
.if \\n(BB=1 .ds AA [single existing comma is last character]
.nr BB 0
..
.\" ----------------------------------------------------------------
.ds DATE*FULL Friday, December 31, 2038
.sp 3c
Full date is: \*[DATE*FULL].
.br
Short date is: \*[DATE*SHORT].
.\" ----------------------------------------------------------------
Of course, it's inefficient, because it has to repeat all
the processing every time you expand DATE*SHORT.
> > Or there's a `.while' IIRC. :-)
The ".while" construct isn't strictly necessary,
because the roff language supports recursion. 8-)
- [groff] Changing A Defined String, Robert Thorsby, 2018/01/24
- Re: [groff] Changing A Defined String, Ralph Corderoy, 2018/01/25
- Re: [groff] Changing A Defined String, Steffen Nurpmeso, 2018/01/25
- Re: [groff] Changing A Defined String, Tadziu Hoffmann, 2018/01/25
- Re: [groff] Changing A Defined String, Robert Thorsby, 2018/01/25
- Re: [groff] Changing A Defined String, Tadziu Hoffmann, 2018/01/27
- Re: [groff] Changing A Defined String, Steffen Nurpmeso, 2018/01/27
- Re: [groff] Changing A Defined String, Tadziu Hoffmann, 2018/01/27
- Re: [groff] Changing A Defined String, Steffen Nurpmeso, 2018/01/27
- Re: [groff] Changing A Defined String, Robert Thorsby, 2018/01/28
- Re: [groff] Changing A Defined String, Peter Schaffter, 2018/01/28
- Re: [groff] Changing A Defined String, Robert Thorsby, 2018/01/28