groff
[Top][All Lists]
Advanced

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

Re: [Groff] question regarding PIC and variable scoping


From: Werner LEMBERG
Subject: Re: [Groff] question regarding PIC and variable scoping
Date: Mon, 24 Jun 2002 19:32:12 +0200 (CEST)

> [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]