On 11-Dec-05 Heinz-Jürgen Oertel wrote:
> Thanks Ted,
> The reason for placing some values in a "global" variable is
> avoiding a large number of macro arguments having always the same
> value. Like with the  variable "slant" in my example.
> Look at the example I'm just trying:
> 
> ----------------
> .fam H
> .PS
> 
>     slant = .2
> 
> 
> define arrowbox { [
> 
>     box xslanted -slant color $1 $3
>     box xslanted slant color $2  $3 \
>       with .ne at last box.se + ( -slant, 0)
>     # place a box centered above both slanted boxes
>     box ht 2*boxht invisible \
>       with .ne at 1st box.ne + ( -(slant/2),0)
> ] }
> .PE
> 
> .PS
> arrowbox("darkgreen", "darkgreen") \
>       "\m[white]1st"  "first" "colored" "box"
> arrowbox("darkgreen", "darkgreen") \
>       "2nd"  "second" "colored" "box"
> arrowbox("darkgreen", "darkgreen") \
>       "3rd"  "third" "colored" "box"
> arrowbox("darkgreen", "darkgreen") \
>       "4th"  "fourth" "colored" "box"
> .PE
> 
> .PS
> slant = .3
> arrowbox("tomato", "tomato") \
>       "\m[black]1st"  "first" "colored" "box"
> move -0.2
> arrowbox("tomato", "tomato") \
>       "2nd"  "second" "colored" "box"
> move -0.2
> arrowbox("tomato", "tomato", outline "white") \
>       "3rd"  "third" "colored" "box"
> move -0.2
> arrowbox("tomato", "red") \
>       "4th"  "fourth" "colored" "box"
> .PE
> ---------------------
> The result is attached.
> Is the only way extending pic to accept strings in expressions, or at
> least 
> in variable assignments?
> 
>  Regards 
>    Heinz

I have found out a way to do it -- essentially, you use the macro
mechanism, but the trick is to define the macro so that the
quotation marks are included in the replacement text.

To take your simple box example as illustration:

.PS
define bcolor { "red" }

define cbox {
    box wid $1 color bcolor
}
.PE
.PS
cbox(1) "this is red"
define bcolor { "yellow" }
cbox(1) "this is yellow"
.PE 

This ensures that occurrences of

  bcolor

are replaced by

  "red"

or

  "yellow"

*including* the quotation marks!

Best wishes,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 11-Dec-05                                       Time: 21:29:45
------------------------------ XFMail ------------------------------


_______________________________________________
Groff mailing list
Groff@gnu.org
http://lists.gnu.org/mailman/listinfo/groff

Reply via email to