From 494a58cca92202647e6a1b726e1dcdb041ffe038 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sun, 28 Feb 2016 20:59:51 +0100 Subject: [PATCH] main.c, add variable 'batchmode' which is set when command line option `-b' is active --- examples/control_structs/if-batchmode.cir | 31 +++++++++++++++++++++++ src/main.c | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 examples/control_structs/if-batchmode.cir diff --git a/examples/control_structs/if-batchmode.cir b/examples/control_structs/if-batchmode.cir new file mode 100644 index 000000000..b26b345c4 --- /dev/null +++ b/examples/control_structs/if-batchmode.cir @@ -0,0 +1,31 @@ +use $batchmode + +* use $batchmode variable to steer control flow +* +* start either with +* ngspice -b -r rawfile.raw if-batchmode.cir +* or with +* ngspice if-batchmode.cir + +v0 1 0 dc 1 +R1 1 2 1k +C1 2 0 1u + +.tran 100u 10m uic +.print tran all + +.control + +if $?batchmode + echo "Info: batchmode has been set by command line option -b" + echo +else + echo "Info: batchmode has not been set" + echo + unset ngdebug + tran 100u 10m uic + plot v(2) +end + +.endc +.end diff --git a/src/main.c b/src/main.c index 214b72a08..33baccfb4 100644 --- a/src/main.c +++ b/src/main.c @@ -923,8 +923,9 @@ main(int argc, char **argv) case 'b': /* Batch mode */ { bool x_false = FALSE; + bool x_true = TRUE; cp_vset("addcontrol", CP_BOOL, &x_false); - + cp_vset("batchmode", CP_BOOL, &x_true); ft_batchmode = TRUE; } break;