In this topic:
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.
RegisterUserFunction Function-Name Script-Name [min-num-args] [max-num-args]For details see RegisterUserFunction.
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.
Arguments @rv arg1 Let rv = 2*arg1Save this to a file called - say - times_two.sxscr and place it in the script directory. Now, register the script as a function called "Times2". To do this, execute the command:
RegisterUserFunction Times2 times_two 1 1The definition is now complete. To test it type at the command line:
Show Times2(2)You should see the result:
Times2(2) = 4
◄ Event Scripts | User Defined Binary Functions ▶ |