next up previous contents index
Next: The printf Command Up: Input and Output Commands Previous: The load Command   Contents   Index


The print Command

The print command is used to print vector data on-screen or to a file using output redirection.

print [/format] [col | line] expr [...]
The command prints the values of the given expressions to the standard output.

If command line input can be recognized as an expression list, the print command will be invoked implicitly. In this case, the line cannot contain directives or a format string, This saves a bit of typing when using the WRspice command line as a calculator, for example.

The default is to use exponential format for all values, with the number of digits given by the numdgt variable. However this, and some other presentation attributes, can be specified in the format string, if given. If given, the format string must be the first argument, and the string must start with a '/' (forward slash) character. The syntax is further described below.

All vectors listed will be printed in the same format, except for the scale vector, which is printed by default in the col mode, which is printed with the default notation.

If line is specified, the value of each expression is printed on one line (or more if needed). If all expressions have a length of 1, the default style is line, otherwise col is the default.

If col is specified, the values are printed in columns. This is the default if any of the vectors are multi-valued. This mode makes use of the height and width variables to define the page size. By default, per-page formatting is applied, with page eject characters between pages. With column formatting, by default the scale vector (time, frequency) will be shown in the first column. If there are more vectors that can be accommodated with the page width, the print will be repeated, with a new set of columns (other than the scale) until all variables have been printed.

If the expression is ``all'', all of the vectors in the current plot are printed. If no arguments are given, the arguments to the last given print command are used. If only the format argument is given, the arguments from the last given print command other than the format are used, with the new format.

If the argument list contains a token consisting of a single period (``.''), this is replaced with the vector list found in the first .print line from the input file with the same analysis type as the current plot. For example, if the input file contains

.tran .1u 10u
.print tran v(1) v(2)
then one can type ``run'' followed by ``print .'' to print v(1) and v(2).

The related syntax .@N is also recognized, where N is an integer representing the N'th matching .print line. The count is 1-based, but N=0 is equivalent to N=1. The token is effectively replaced by the vector list from the specified .print line found in the circuit deck.

The print command is responsive to the following variables.

width, height
These option variables set the page size (in characters and lines) assumed for the output when directed to a flie or device. If not set, a standard A-size page is assumed. When printing on-screen, the actual screen or window size will be used.

nopage
This boolean option will suppress page breaks between pages when set. This is always true when printing to a screen. Page breaks consist of a form-feed character, which may be followed by a two-line page header.

The following variables are all booleans, and apply only to column mode of the print command.

printautowidth
When set, the window width or the setting of the width variable is ignored, and a line width sufficient to include columns for all variables being printed is used, if possible. There is a hard limit of 2048 characters in the lines. Variables that don't fit are printed subsequently, as in the case with printautowidth not set.

printnoheader
When set, don't print the top header, which consists of the plot title, circuit name, data, and a line of ``-'' characters (three lines). This is normally printed at the top of the first page of output.

printnoindex
When set, don't print the vector indices, which are otherwise printed in the leftmost column of each page.

printnopageheader
When set, don't print the page header. The page header, which consists of the variable names at the top of each column and a line of ``-'' characters, is otherwise printed at the top of each page of output.

printnoscale
When set, don't print the scale vector in the leftmost data column. This is otherwise done for each set of variables printed. The Spice3 noprintscale variable is an alias, but deprecated.

The syntax of the format string to the print command allows overriding the states of the switches listed above while printing. The format string, if used, must be the first argument given to the print command, and must begin with a `/' (forward slash) character. It contains no space, and is a sequence of the characters and forms shown below, all of which are optional.

integer
The integer is the number of figures to the right of the decimal point to print. If not given, the value of the numdgt variable is used if set, otherwise a default of 6 is used.

f
If `f' is found in the string, data values will be printed using a fixed-point format, rather than the default exponential format.

The remaining options apply/unapply the switches, whose defaults are set by the print... variables described above. The format string always overrides the variables.

-
Negate the effect of options that follow.
+
Don't negate effect of options that follow. This is redundant unless it follows `-'.
a
Take printautowidth as if set, or not set if negated.
b
Take nopage as if set, or not set if negated.
h
Take printnoheader as if set, or not set if negated.
i
Take printnoindex as if set, or not set if negated.
p
Take printnopageheader as if set, or not set if negated.
s
Take printnoscale as if set, or not set if negated.
n
Alias for ``abhips''.

Examples

print /3f+ahi-ps ...
Print using a fixed three decimal place format, and as if printautowidth, printnoheader, and printnoindex were set, and printnopageheader and printnoscale were unset.
print /n ...
Print the vectors listed, and nothing but the vectors listed. This is useful when one wants to feed a simple list of numbers to another application.
print /n-s ...
As above, but print the scale in the first column. The `-' can be used as shown to undo individual implicit settings from `n'.
print /3f v(5)
This prints v(5) to three decimal places in fixed-point notation.
print /4f v(2) v(3) v(4) > myfile
This prints the vectors to four decimal places in the file "myfile".
print 2*v(2)+v(3) v(4)-v(1)
This prints the computed quantities using the default format.


next up previous contents index
Next: The printf Command Up: Input and Output Commands Previous: The load Command   Contents   Index
Stephen R. Whiteley 2022-09-18