Knowledge Base Article

Using the Equation Editor Algorithm Tab

In the Equation Editor, go to the Algorithm Tab. The Algorithm Tab is the primary programming user interface for coding a vCalc equation.  vCalc currently uses the Groovy programming language with a few vCalc specific additions.  For general information on Groovy, see  groovy-lang.org.  For examples of Groovy in vCalc, you can always look at the Algorithm of any existing vCalc equation within the equation's wiki page by selecting "See Algorithm" at the bottom. You can also see standard Groovy syntax used in vCalc by clicking HERE.

There are three sections to the Algorithm Tab:  Coding Window (top left), Equations and Constants Window (right), and the User Inputs Window (bottom when user inputs are coded in the Coding Window).                             Coding Window

Within the Algorithm Tab, you will see the Coding Window.  It is a blank section with line numbers down the left side.  Click inside the window to enter your vCalc (Groovy) code.
Note: For security purposes, vCalc precludes global variables and all variables must be defined locally with the def statement.

User Input Variables

To create a User Input variable, define a local variable,  and and assign its value from vCalc's reserved parameter map args,  e.g. def b = args.b.  In this example, vCalc will:

1. Recognize the use of the args parameter map, create a user input variable b, and automatically display the user input option menu at the bottom of the coding window.
2. Create a local variable b and assign to it the value entered by the user for b,

User Inputs Window

The User Inputs have the Variable name, a Markup field, Label, Instructions, Datatype, Units, Values and Defaults.

• The Variable name is automatically populated when the args map is used in the Coding Window.  The # before a variable name (e.g. #dog) has the same effect, but the # may not be supported in this way in the future.  Therefore, use args. (e.g. args.dog).
• The Markup is a display option for that input parameter (See AsciiMath Help).
• The Label is where you can enter text to help describe the input parameter.  This is displayed to the equation users. Note: this field defaults to ASCIIMath (Mathml).  Therefore, math symbol replacements occur.  If you see math symbols in your label, put the text in double quotes.  "in" produces in, but without the quotes it produces the set inclusion symbol.
• The Instructions is meant to be additional information to describe the input parameter if the Label description is too short.
• The Datatype is used to designate where the input parameter is an integer, decimal, or string.
• The Units feature lets you associate units with your input parameter (See Help with Units).
• The Values section lets you create a list separated by commas that is turned into the list of possible choices when using the equation.  If provided, then when using the equation a user must choose their value from one of the items provided in this list.  Note: Using values automatically sets the datatype to String.
• The Default is the value that is automatically populated for the input parameter.  However the user can override this when using the equation.

Note: you can use utilize vCalc equations and constants with function calls from within your equation, and in essence use existing equations and constants as subroutines to minimize redundancy of code, simplify maintenance and reduce errors.  For more on this topic click HERE.

For examples of Groovy code working in a vCalc equation, you can always click on the "Show Algorithm" at the bottom of any vCalc's equation wiki page to see its groovy code. You can also find help in the following help documents: