The purpose here is to demystify this process even for the newcomer to programming. Being able to create values which capture and manipulate information is essential to take advantage of the enormous power of Control. This page describes how to make a variable a formula and some errors to avoid in doing so. See also cfl_ch_5-variables.

CFL uses variables in at least 2 ways. They are used to hold lists and tables and to capture information on a Pricing form - e.g. Height is usually the variable attached to the SpinEdit Object on the pricing form for entering Height. They are even more widely used to house formulas. You can enter any CFL formula in a variable and name it something descriptive. For example, probably all Cyrious applications have a Variable named Area. Edit that variable and you will see an example of what we are describing here. The code will look like

`Height * Width`

THIS SCREEN SHOT SHOWS HOW THE SYSTEM VARIABLE IS SET UP: Note the formula in the “Use Formula” field.

how-to_make_coding_easier_with_the_formula_builder will generally catch any errors you make. One error it may not catch is when you have variable “A” referring to another variable's formula in, let's say, Variable “B” and the formula in Variable “B” is referring to a result in Variable “A”. This is called a Circular Loop, and, if Cyrious detects it, you will get a message to that effect. If Cyrious does not detect it, expect bizarre results up to an including having Cyrious just vanish from your screen. Note in the example above you see an option to select the Unit Type, Units For Entering Values, Units For Displaying Values. I would recommend leaving these set to their default value which is None and then letting your formulas do the calculations if they are returning square inches or square feet. If you do choose to use them, be aware that you will usually need to include descriptors such as the following which are required when working with the System Area Variable: Area in SqFeet or Area in SqInches.

1. Create and name your variable. Set the variable type to number.
2. Below the heading “Answer Required”, find the field with a radio button beside it saying, “Use Formula”. Check that radio button and the grayed out area will become white. The how-to_make_coding_easier_with_the_formula_builder button will be active. Click on that and enter your formula and save your variable
3. BE VERY CAREFUL NOT TO ENTER YOUR FORMULA IN THE “USE FORMULA” BOX UNDER THE “VALID RANGE” HEADING. That won't do any harm, but your variable will not work to produce the formula result.
4. Be sure to load your variable into the product for which you have designed it, or it will not be accessible.

Contributor: Steve Gillispie, Acorn Sign Graphics

Date: 8/3_/2009

Version: Control 4.3_