In this Topic Hide
The SIMetrix script language provides a method of creating user defined functions that can be used in any front end expression. These expressions may be used in scripts, on the command line and even within a schematic template property.
User defined functions are used to define some of the goal functions designed for performance and histogram analysis. The scripts for these all begin "uf_" and are registered using the script "reg_user_funcs". The source for these can be found on the installation CD.
User defined functions are defined as a script. The arguments to the function and the return value from the function are passed as the script's arguments. The script's first argument is passed by reference and is the return value while the remaining arguments are the arguments passed in the call to the function. The function may have up to seven arguments and they may be of any type. See example below.
For the expression evaluator to recognise the function name, the script and function name must be registered. This is done with the RegisterUserFunction command. The definition of this is:
RegisterUserFunction Function-Name Script-Name [min-num-args] [max-num-args] |
Note that function registration is not persistent. That is the registration only lasts for the current session. If you wish to make a permanent function definition, place the RegisterUserFunction command in the startup script.
Here is a trivial example. The following shows the steps to create a function that multiplies a number by 2. First the script
Arguments @rv arg1 |
Let rv = 2*arg1 |
RegisterUserFunction Times2 times_two 1 1 |
Show Times2(2) |
Times2(2) = 4 |
|