If your script ever needs to work with equations, you will frequently want to access either the left hand side (name) of the equals sign or the right hand side (value) of the equals sign. The following functions perform these tasks:
IN this example there is are two equations, "x=1" and "y=2".
Get equations by name.
Both of these scripts will produce this output in the debug window
Since MWO handles the entire equation as a string through the Expression method (i.e. Equation.Expression), I usually call these functions inline, as follows:
Manipulating groups of Equations
MWO handles the entire group of equation as a string through the Expression method (i.e. Equation.Expression). Each equation in the group separated from the next equation with carriage return and line feed characters. To read all equations in the group:
To set the group of equations:
So the following works only for groups:
To get the number of groups of equations:
To loop through groups of equations:
There are some equation properties for individual equations within the group. It takes two commands. First, you tell it which eqn you want to work on, and then you make the actual property change. (In the following code second equation in the group is disabled). To select which equation in the group to access, use the "ActiveIndex" property on the equation object:
So, when you access the Enabled or Tune properties, it works on whatever equation in the group is selected by ActiveIndex. By default, ActiveIndex is set to one.
If equations were organized as separate equations without making a group of equations they will be treated as they were before, as the usual collection of equations.