In this Topic Hide
Scripts are executed by typing their file name at the command line, running them from the script editor, or dragging and dropping the file to the Command shell. Additionally, scripts can be assigned to a key or menu. See User Defined Key and Menu Definitions.
If a full pathname is not given, SIMetrix first searches a number of locations. The rules are a little complicated and are as follows:
You can pass data to and from scripts using arguments.
To pass a value to a script, simply place it after the script name. E.g.
my_script 10 |
Arguments num |
if ExistVec('$arg1') then |
.. action if arg 1 passed |
else |
.. action if arg 1 not passed |
endif |
When an argument is passed by value, the script in effect obtains a local copy of that data. If it subsequently modifies it, the original data in the calling script remains unchanged even if a variable name was used as the argument. The alternative is to pass by reference which provides a means of passing data back to the calling script. To pass by reference you must pass a variable prefixed with the @ character. E.g.
Let var = 10 |
my_script @var |
Arguments @var |
Let var = 20 |
Optional arguments passed by reference work the same way as arguments passed by value except that instead of using the variable $argn you must use $varn. You do not need to use @ when accessing arguments in this way. See the internal script define_curve for an example.
There is currently a limitation that means you can't use an argument passed by reference directly in a braced substitution. E.g.
{var} |
In many computer languages it is usually recommended that you pass large data items such as arrays by reference as passing by value involves making a fresh copy which is both time consuming and memory hungry. Passing by reference only passes the location of the data so is much more efficient. In the SIMetrix script language, however, you can efficiently pass large arrays by value as it uses a technique known as copy on write that does not make a copy of the data unless it is actually modified.
All the scripts needed for the standard user interface are actually built in to the executable file. The source of all of these can be found on the installation CD.
You can watch the script being executed line by line by typing at the command line before starting the script:
Set EchoOn |
Unset EchoOn |
Run the script by typing at the command line:
ScriptPause ; scriptname |
Note that ScriptPause only remains in effect for the first script. Subsequent scripts will execute normally.
Press escape key.
To pause a currently executing script.
Press shift-F2. Note that it is not possible to run other commands while a script is paused but you can single step through it using F2.
Press ctrl-F2
The startup script is executed automatically each time SIMetrix is launched. By default it is called startup.sxscr but this name can be changed with in the options dialog box. (
). The startup file may reside in the script directory (defined by ScriptDir option variable) or in a user script directory (defined by UserScriptDir option variable).The most common use for the startup script is to define custom menus and keys but any commands can be placed there.
To edit the startup script, select the
menu item.
|