Hello Dan,

I looked for a way to embed conditional strings into the label for library
objects.  For example, if a parameter is not null then print a string:
<<
...
/@ac_flag ()
...
begingate

mark
...
{ () @ac_flag ne {(AC)}if  }
...
label

Or something like that.  I looked in file.c and it appears that there isn't
support for embedded PS in the mark macro.  I tried a bunch of different
ways to wiggle this in.

What I'm trying to do is define an independent voltage source that can
optionally have the AC and DC parameters.  By default these are not
defined, but if they are, then include that information in the label.  This
is only for aesthetic purposes.  What really matters is getting these
things into the spice card if needed, and I've figured that out:

mark
    (\)) @sin_phase ( ) @sin_theta ( ) @sin_td ( ) @sin_freq ( ) @sin_va ( )
@sin_vo
    ( SIN\()
    @ac_phase ( ) @ac_mag ( ) @ac_flag ( )
    @dc_value ( ) @dc_type ( ) @dc_flag  ( )
    ( %ps.p %ps.m )
    @index (spice:V) {/Times-Roman cf} ctmk 20 0.000 1.000 -336 -160
infolabel

What there is, is a way to specify a Tcl expression as a parameter.
Within xcircuit, you can do this by bringing up the parameter window
(Ctrl-P) and clicking on "New..." then selecting "Expression".  There is
special handling for parameters in the form "lindex {<list>} <value>"
which generates a list from which the parameter value can be selected.
In the PostScript the parameter looks like:

        /@ac_flag (0) (lindex {0 1} 0) pop
        /@dc_flag (0) (lindex {0 1} 0) pop

The "()" denotes a PostScript string;  the Tcl expression is encoded in
PostScript as a string, followed by "pop" so that when the PostScript
is displayed, the Tcl expression goes away.  When read into XCircuit,
the Tcl expression is read in and retained, also as a string, and
evaluated by the interpreter.  The result is the actual value of the
parameter, and is what ends up in the first set of parentheses when the
file is written out, so that's what shows up in the PostScript.

Now, to generate a string from those values, you can define another
expression parameter (this assumes the existence of the @ac_phase, etc.,
parameters you defined above):

/p_expr1 () (if {@ac_flag == 0} {return ""} else {concat "AC" @ac_mag @acphase}) pop /p_expr2 () (if {@dc_flag == 0} {return ""} else {concat "DC" @dc_type @dc_value}) pop

(note that I am not bothering to look up the syntax for the SPICE line,
which I don't remember off the top of my head).

Finally, you just need to use those expressions above inside the
mark ... ctmk group:

        mark (\)) p_expr1 ( ) p_expr2 ( ) ...

That should do what you want.  You can even do all of this from inside
xcircuit without having to hand-edit the postscript, although I admit
to doing a lot of hand-editing myself.

                                        Regards,
                                        Tim


+--------------------------------+-------------------------------------+
| R. Timothy Edwards (Tim)       | email: t...@opencircuitdesign.com    |
| Open Circuit Design            | web:   http://opencircuitdesign.com |
| 19601 Jerusalem Road           | phone: (240) 489-3255               |
| Poolesville, MD 20837          | cell:  (408) 828-8212               |
+--------------------------------+-------------------------------------+

_______________________________________________
Xcircuit-dev mailing list
Xcircuit-dev@opencircuitdesign.com
http://www.opencircuitdesign.com/mailman/listinfo/xcircuit-dev

Reply via email to