Page 728 - ExtendSim User Guide
P. 728

702
Math and Statistical Distributions
Equation-based blocks
• Other editing commands, such as matching braces, are supported
☞ Code completion is enabled in both the equation area and the Equation Editor window (which also has a Code Completion button). Code completion (F8) makes it easier to recall function names and their arguments
To see the Equation Editor:
Open the Reservoir 3 model located at \Examples\Tutorials\Continuous
In the model, open the dialog of the Equation block; it is labeled Calculate Overflow
In the block’s dialog, click Open Equation Editor. The window that opens is shown in the screenshot to the right.
As you can see, the con-
tents of the window
automatically uses the indenting and code colorization features. The Code Completion button at the bottom of the window is useful when searching for a function or to get the correct argu- ment list. To use code completion, type the first part of the function name in the code pane, then click the Code Completion button or press F8. If the function that appears isn’t the one you want, click F8 again until the correct function appears.
Include files for equations
It is common that several blocks would use the same or similar variable definitions and func- tions. Include files simplify programming tasks that are repeated in multiple blocks. They are especially helpful when you define your own functions for one block and want other blocks to have access to those functions. In addition, include files allow you to use user-defined func- tions and procedures in equation-based blocks, which don’t directly support custom functions.
For those who are building complex equations, most of the equation-based blocks have an interface for adding include files. This feature is implemented in the Equation and Query Equation blocks (Value library), Equation(I), and the Queue Equation, and Query Equation(I) blocks (Item library).
Include files in equations are similar to the standard ModL include header files used when cre- ating a block and discussed in the Developer Reference. They can contain ModL symbol defi- nitions such as #define, conditional compilation statements such as #ifdef, and function definitions.
The main differences between the two methods of using include files are:
• Includefilesusedwithequationsarenormallysavedinthesamelocationasthemodelusing them; this makes it easy to move both the model and the includes it uses to a different loca- tion. Include files used in block code should be saved in the Extensions/Includes folder.
• Include files are added to block code via the #include syntax in the code, such as #include “filename.h”. However, include files in equations are added via an interface (Use include files) in the equation block’s dialog. You cannot use the #include syntax in an equation block.
To create a new include file for an equation-based block:
Equation Editor window showing overflow equation
How To


































































































   726   727   728   729   730