In this Topic Hide
Scripts are composed of a sequence of statements. Statements usually comprise at least one command and optionally control words such as if and then. A command is a single line of text starting with one of the command names listed in the Command Reference.
There are six types of statement. These are:
Commands begin with one of the names of commands listed in the Command Summary. A command performs an action such as running a simulation or plotting a result. E.g.:
Plot v1_p |
All commands must start on a new line or after a semi-colon. They must also end with a new line or semi-colon.
A command statement is a sequence of one or more commands.
Many commands have switches. These are always preceded by a '/' and their meaning is specific to the command. There are however four global switches which can be applied to any command. These must always be placed immediately after the command. Global switches are as follows:
An if statement is of the form:
if expression then |
statement |
endif |
if expression then |
statement |
else |
statement |
endif |
if expression then |
statement |
[[elseif expression then |
statement ]...] |
else |
statement |
endif |
if NOT SelSchem() then |
echo There are no schematics open |
exit all |
endif |
if length(val)==1 then |
echo {refs[idx]} {val} |
else |
echo Duplicate reference {refs[idx]}. Ignoring |
endif |
if opts[0] && opts[1] then |
let sel = 1 |
elseif opts[0] then |
let sel = 2 |
else |
let sel = 3 |
endif |
In form1, if the expression resolves to a TRUE value the statement will be executed. (TRUE means not zero, FALSE means zero). In the second form the same happens but if the expression is FALSE the statement after the else is executed. In the third form, if the first expression is FALSE, the expression after the elseif is tested. If that expression is TRUE the next statement is executed if not control continues to the next elseif or else.
While statements are of the form:
do while expression |
statement |
loop |
while expression |
statement |
endwhile |
do while GetOption(opt)<>'FALSE' |
let n = n+1 |
let opt = 'LibFile' & (n+99) |
loop |
In while loops the expression is evaluated and if it is TRUE the statement is executed. The expression is then tested again and the process repeated. When the expression is FALSE the loop is terminated and control passes to the statement following the endwhile.
A script statement is a call to execute another script. Scripts are executed initially by typing their name at the command line (or if the script has .sxscr extension, the .sxscr can be omitted) or selecting a key or menu which is defined to do the same. Scripts can also be called from within scripts in which case the call is referred to as script statement. Note that a script may not call itself.
There are four types:
exit while |
exit for |
exit script |
exit all |
exit for does the same for for-loops.
exit script will force the current script to terminate. Control will pass to the statement following the call to the current script.
exit all will abort all script execution and control will return to the command line.
|