comments, new examples

This commit is contained in:
h_vogt 2009-12-28 08:34:55 +00:00
parent 8cee489660
commit 28d5114f43
3 changed files with 144 additions and 10 deletions

View File

@ -1,3 +1,7 @@
2009-12-22 Holger Vogt
* measure.c: comments,
/examples/control_structs/repeat3.sp: new examples snippets included
2009-12-22 Holger Vogt
* measure.c: bugfix (%f replaced by %e)

View File

@ -1,5 +1,10 @@
*test sequence for repeat
Test sequences for ngspice control structures
*vectors are used (except foreach)
*start in interactive mode
.control
* test for while, repeat, if, break
let loop = 0
while loop < 4
let index = 0
@ -9,8 +14,135 @@
break
end
end
echo
echo index "$&index" loop "$&loop"
let loop = loop + 1
end
.endc
* test sequence for while, dowhile
let loop = 0
echo
echo enter loop with "$&loop"
dowhile loop < 3
echo within dowhile loop "$&loop"
let loop = loop + 1
end
echo after dowhile loop "$&loop"
echo
let loop = 0
while loop < 3
echo within while loop "$&loop"
let loop = loop + 1
end
echo after while loop "$&loop"
let loop = 3
echo
echo enter loop with "$&loop"
dowhile loop < 3
echo within dowhile loop "$&loop" $ output expected
let loop = loop + 1
end
echo after dowhile loop "$&loop"
echo
let loop = 3
while loop < 3
echo within while loop "$&loop" $ no output expected
let loop = loop + 1
end
echo after while loop "$&loop"
* test sequence for foreach
echo
foreach outvar 0 0.5 1 1.5
echo parameters: $outvar $ foreach parameters are variables, not vectors!
end
* test for if ... else ... end
echo
let loop = 0
let index = 1
dowhile loop < 10
let index = index * 2
if index < 128
echo "$&index" lt 128
else
echo "$&index" ge 128
end
let loop = loop + 1
end
* simple test for label, goto
echo
let loop = 0
label starthere
echo start "$&loop"
let loop = loop + 1
if loop < 3
goto starthere
end
echo end "$&loop"
* test for label, nested goto
echo
let loop = 0
label starthere1
echo start nested "$&loop"
let loop = loop + 1
if loop < 3
if loop < 3
goto starthere1
end
end
echo end "$&loop"
* test for label, goto
echo
let index = 0
label starthere2
let loop = 0
echo We are at start with index "$&index" and loop "$&loop"
if index < 6
label inhere
let index = index + 1
if loop < 3
let loop = loop + 1
if index > 1
echo jump2
goto starthere2
end
end
echo jump
goto inhere
end
echo We are at end with index "$&index" and loop "$&loop"
* test goto in while loop
echo
let loop = 0
if 1 $ outer loop to allow nested forward label 'endlabel'
while loop < 10
if loop > 5
echo jump
goto endlabel
end
let loop = loop + 1
end
echo before $ never reached
label endlabel
echo after "$&loop"
end
*test for using variables
* simple test for label, goto
echo
set loop = 0
label starthe
echo start $loop
let loop = $loop + 1 $ expression needs vector at lhs
set loop = "$&loop" $ convert vector contents to variable
if $loop < 3
goto starthe
end
echo end $loop
.endc

View File

@ -2,6 +2,9 @@
Entry point is function do_measure(), called by fcn dosim()
from runcoms.c:335, after simulation is finished.
In addition it contains the fcn com_meas(), which provide the
interactive 'meas' command.
$Id$
*/
@ -127,14 +130,9 @@ com_meas(wordlist *wl) {
static bool
chkAnalysisType( char *an_type ) {
/*
if ( strcmp( an_type, "ac" ) != 0 && strcmp( an_type, "dc" ) != 0 &&
strcmp( an_type, "noise" ) != 0 && strcmp( an_type, "tran" ) != 0 &&
strcmp( an_type, "fft" ) != 0 && strcmp( an_type, "four" ) != 0 )
*/
/* only support tran analysis type for now */
/* only support tran, dc, ac, sp analysis type for now */
if ( strcmp( an_type, "tran" ) != 0 && strcmp( an_type, "ac" ) != 0 &&
strcmp( an_type, "dc" ) != 0)
strcmp( an_type, "dc" ) != 0 && strcmp( an_type, "sp" ) != 0)
return FALSE;
// else if (ft_batchmode == TRUE) return FALSE;
else return TRUE;