<@U02UAUGSQ22> ```ngspice 36 -&gt; let x=11 ngspic...
# xschem
s
@Harald Pretl
Copy code
ngspice 36 -> let x=11
ngspice 37 -> set y=test{$&x}.raw
ngspice 38 -> echo $y
test11.raw
ngspice 39 -> write $y
binary raw file "test11.raw"
h
@Stefan Schippers Yeah, this is exactly what I need. I was somehow lost in the $&{} mess 🙂 No exactly self-explanatory.
s
it is quite ugly indeed. See section
17.8
or the ngspice user manual. They have so called csh style variables and 'vectors'. the
let x=11
creates a 1-length vector. All numeric stuff is done with vectors, including a loop variable. Then you have these csh style variables and assigning a vector to a csh variable is done with
$&
. I have struggled myself a lot in this jungle.
h
and what exactly is the difference between
let
and
set
? this is where messed up.
s
@Harald Pretl use
let
for anything that has a numeric value and you need to do some calculations with (they call these '`vectors`' even for 1-length). Use
set
to create '`variables`'. These are very similar to shell variables, but as far as i know you can't do math on these. On the other hand these '`variables`' can contain anything. The following lines show how to go back and forth with variables and vectors. Use
echo
with
$
to get value of variables, use
print
to get value of vectors. Vectors can be operated on as a whole:
let power = v(out) * i(vmeasure)
creates a new vector representing a power, this can be plotted like any other simulation variable.
Copy code
ngspice 270 -> set a=1
ngspice 271 -> echo $a
1
ngspice 272 -> let b=$a
ngspice 273 -> let b = b + 1
ngspice 274 -> print b
b = 2.000000e+00
ngspice 275 -> set c = $&b
ngspice 277 -> echo $c
2
👍 1