.TEXT -- User-Defined Strings

Syntax: .text <name>=<string literal>

Example: .text DIODE = "1N4148"

The .text directive allows the creation of user-defined strings. It allows associating a string with a name. That name can be used, e.g., a model or subcircuit name and then by changing the string associated with the name, a different model or subcircuit is used throughout the simulation.

The .text statement can be included inside a subcircuit definition to limit the scope the string value to that subcircuit. Text substitution evaluation is done before the expanding subcircuits to a flat netlist.

To invoke text substitution and text expression evaluation, enclose the expression in pipe, '|', characters. The enclosed expression will be replaced with string value of the name inside the pipes.

Below is an example using both a global scope and local .text definitions.

*
V1 1 0 PULSE(0 1 0 1u 1u .5m 1m)
R1 |node| 1 |"1" + "K"|
C1 |node| 0 |foobar|
X1 2 div 0 NIX
.text node="2"
.text foo=".1" bar="u"
.text foobar = foo + bar
.tran 3m
.text top="100k"
.text bot="100k"
.subckt nix a b c
.text bot="1Meg"
R1 a b |top| ; uses global scope definition of top
R2 b c |bot| ; uses locally scope definition of bot
.ends nix
.end

And below resultant circuit after .text processing and subcircuit expansion.

*
v1 1 0 pulse(0 1 0 1u 1u .5m 1m)
r1 2 1 1k
c1 2 0 .1u
r:1:1 2 div 100k
r:1:2 div 0 1meg
.tran 3m
.end

Note that pipe characters can include string literals, i.e., |"1" + "K"| is resolves to 1K. This will only happen if there exists at least one .text statement in the netlist. This is because .text is a new feature in LTspice. If there are no .text statements, the pipe character has no special meaning in the interest of running existing simulation in the same way.