groff
[Top][All Lists]
Advanced

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

[Groff] question regarding PIC and variable scoping


From: Dwight Aplevich
Subject: [Groff] question regarding PIC and variable scoping
Date: Mon, 24 Jun 2002 20:13:20 -0400

Actually, no, your first reply was not in error; it was just
not the whole story.  The question is whether there is
external access to block variables.

In the most recent example below, x is not a block
variable but is external to it. This gives another
mechanism for exporting calculated values,
but not access to block variables.

A documentation fix is in order, nothing more.

At 07:32 PM 24/06/2002 +0200, you wrote:
> [About accessing a GNU pic variable in a block from outside]

> > I think we agree that the above reference implies that i can do
> > something like last [].variable.  This is exactly the documentation
> > i was refering to.  So either the documentation should clarify this
> > important distinction between variables and labels (and take out
> > "variable or") or perhaps there is a way to add that functionality?
>
> This functionality is already available.  I've added the following to
> pic.ms:
>
>   Variables in a block can't be directly accessed from outside; they
>   must be converted into a position:
>
>     A: [
>          xy = 5;
>          Xy: (xy,0);
>        ]
>     print A.Xy.x

Oops!  Error!  Please ignore this.  The right way to export the value
of a variable within a block to the outside is to use the `:='
operator.  The only (minor) restriction is that a variable has to be
defined already outside of the block before you can use `:='.

Example:

  .PS
  x=5
  y=5
  [
    x:=3
    y=3
  ]
  print x " " y
  .PE

Result of this is `3 5'.

I've reworded the documentation in both pic.man and pic.ms which was
very misleading IMHO.


    Werner



reply via email to

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