groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Groff] pic problem


From: Ted Harding
Subject: RE: [Groff] pic problem
Date: Wed, 14 Jul 2004 00:00:01 +0100 (BST)

On 13-Jul-04 Larry Kollar wrote:
> The following pic code works right up through the box "32" but doesn't 
> create any boxes within the for loop.
> 
> .P
> This is a test.
> This is only a test.
> .S -3
> .PS 4.5i
> box wid 8 ht 1 "Chassis ID"
> box wid 8 ht 1 "Slot ID"
> box wid 16 ht 1 "Interface/Port Use"
> box wid 1 ht 1 with .nw at 1st box .sw "32";
> for n = 31 to 1 by -1 do {
>         box wid 1 ht 1;
>         print n;
> }
> .PE
> .S
> .P
> If this had been an actual document
> there would have been some content.
> 
> .\" the end
> 
> Any ideas?

A. If you follow the body of the loop by "print n" you find that
n is still 31.

B. It works if the "for" loop is in the form

  for n = 1 to 31 by 1 do {...}

but not in the form you tried. Not even the "print n" does anything.
The implication is that the body of the loop is not executed at all.

C. It also works for "for n = 31 to 31 do {...}"

D. Interestingly, the form

  for n = 31 to 31 by -1  do {
          box wid 1 ht 1;
          print n;
          if n<25 then { n = 35}
  }
  print n

draws 8 boxes, and prints "31/30/29/28/27/26/25/24/34" to the console.

The only way I can account for all of A, B, C, D is that the logic
of the loop 

  for n = a to b by c do {...}

is:

  [1] Set n = a.
  [2] If a > b, break; else execute {...}
  [3] increment a by c [default 1], and go to [2].

which would presuppose that a <= b to start with, and c > 0.
Not the logic one would expect!

How does this behave with 'pic' (non-GNU) in other Unix versions?

Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 14-Jul-04                                       Time: 00:00:01
------------------------------ XFMail ------------------------------


reply via email to

[Prev in Thread] Current Thread [Next in Thread]