On 11-Dec-05 Heinz-Jürgen Oertel wrote: > > Hello, > I'm searching for a way to put strings in pic variable, > but found no way doing it. > What I like to do is something like: > > .PS > bcolor = "red" > > define cbox { > box wid $1 color bcolor > } > .PE > > .PS > cbox(1) "this is red" > bcolor "yellow" > cbox(1) "this is yellow" > .PE
I *think* (but am not absolutely sure) that the reason your approach does not work is that the assignment "=" has the syntax variable = expression and, as far as I can tell, "expression" in pic can only be numeric (or logical), so that there is no such thing as a string-valued expression (or variable). More generally, a string (either quoted literally or as returned by 'sprintf') is an object, like 'box'. However, it is possible to do what you want by macro substitution: .PS define cbox { box wid $1 color $2 } .PE .PS bcolor="red" cbox(1,"red") "this is red" cbox(1,"yellow") "this is yellow" .PE This does not evaluate any expressions: When (e.g.) "red" is encountered in 'cbox(1,"red")' it is substituted for $2 in the definition of 'cbox', i.e. it effectively re-writes 'cbox'. Hoping this helps! Ted. > > Another interesting feature would be if > \n[.M] could return the numerical values of the color components. > In this case one could define a new color which is sometimes darker or > more > bright, or "more red" etc. This can be used to produce shaded colored > boxes > in pic. > > Hope I get help > Regards > Heinz > > > > _______________________________________________ > Groff mailing list > Groff@gnu.org > http://lists.gnu.org/mailman/listinfo/groff -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 11-Dec-05 Time: 14:02:36 ------------------------------ XFMail ------------------------------ _______________________________________________ Groff mailing list Groff@gnu.org http://lists.gnu.org/mailman/listinfo/groff