**Description**

Shows how to pass a number to or convert a number from a variable which has been created as a Unit Variable [our term, not Cyrious's] meaning a variable where the unit option has been selected and a unit like inches has been chosen as shown in the screen shot below. The unit type is Length and the units expected in data entry are inches and the number returned (displayed) is inches..

## Concept

When a pricing_ch_07-global_variables is given a unit designation, any number “stored” for that variable is stored in centimeters. [* The screen shot below shows the System Variable Height set up as Unit Type Length and the Units it expects for entries made to it as well as the other types of units which might be selected]*. Click this link list of all units available for use within Control and their relevant factor formulas that are used internally by Control to calculate the conversion. Thereafter, whenever the variable is called, it returns the basic centimeter value converted to the designated unit. For example, when a 7 is entered in a variable like Height which is an Inch Unit Variable, it actually stores the number as 17.78. Whenever cfl_reference encounters this variable, it divides by 2.54 to convert it back to Inches. When calling the variable in CFL, the correct code is Height in Inches. If the conversion function is omitted, Cyrious will return the 17.78 centimeters number. When passing variables to these numbers as, for example, you would want to do if drawing the height from a Property value, the number must be converted by code to the proper base centimeter number to get the correct result.

## Cautions

Always test code carefully using various magnitudes of numbers in a live product as well as the how_to_preview_test_cfl_coding_resultsr before unleashing it on a user population.

## Steps

- For this example, we show how to take a number from a cfl_ch_6-property_references . There are other situations where you will need to make a conversion such as using a unit variable in a Table Lookup, but it should be easy to divine the correct code from this approach. You will need to have a List with a Property Name which must be entered in the code exactly the same as in the Property.
- So, to use Property values to create default Height and Width numbers in a product, first open the Product and select the Variables tab. Navigate to the Height variable, select, and Edit it.
- Click on the Override button which permits you to create a formula for that variable which will apply only when that variable is used by that product. If usingpricing_ch_11-pricing_plans , be sure to click on the Pricing Plan tab for which you want to create a formula unique to this product. If you want all pricing plans for the product to work the same way, you may need to make the change to the variable in all of them.
- Enter code like the following, substituting the name of your variable and Property and include the “error trap” which is a comma and the number you want the code to return if the property value is not found. In the example below that is “0”. :

ListPropertyValue(VariableName,"Property Name",0)* 2.54 //2.54 is the conversion number to convert this number to the higher centimeters number OR ListPropertyValue(YourVariable,"Height2",0) Inches //Inches is the CFL function which converts Centimeters to Inches //Per Lori the Inches function supplies the multiplier to convert from a number to //centimeters and the function In Inches supplies the Divisor to convert from //centimeters back to inches,

- If the variable you are using is not Inches, substitute the number or CFL function which converts that variable from centimeters to the unit you are using.
- When you are passing a unit variable to another number as, for example, in a Table Lookup, if you are unable to get CFL to parse the unit function (E.G:.In Inches) which we have sometimes found to be the case, you would need to divide the variable's result by the conversion factor to get the correct units.

## Source

Contributor: *Steve Gillispie*, Acorn Sign Graphics

Date:06/03/2009

Version: Control 4.04.40.1003.3102