A variable is a "container" that holds a value. Every variable also has a name that you use to refer to the value contained in the variable. A variable can be

gifs/20000000.gif A field name

gifs/20000000.gif An edit name

gifs/20000000.gif A subscripted field name

gifs/20000000.gif A subscripted edit name

gifs/20000000.gif A shell variable

gifs/20000000.gif A formula variable

When you create a field on a form, you can specify a Field Name and an Edit Field name in the Field Description Screen. Either of these names may be used as a variable in an expression. If the formfile contains several forms, you can name fields on other forms as formname.fieldname, where fieldname is the field name (or edit name) in the form formname. This allows field values from previous forms to be used in formulas on the current form.

You can refer to a subscripted Field Name or Edit Field name as fieldname [expression] or formname.fieldname [expression]. There must be a subscripted field defined in the formfile with a constant subscript equal to the expression, or form will report that the field does not exist when it attempts to evaluate the formula. For example, if you refer to price[product] in a formula and the value of product is 4, there must be a field in the current form named price [4].

Shell variables may also be used in an expression. The data type of shell variables is always string. The shell variable name must be preceded with a $.

A formula variable name consists of 1 to 15 characters. The first character must be a letter, the rest may be letters or digits. Letters may be upper or lower case, but lower and upper case letters are considered different. A formula variable cannot have the same name as a Field Name or Edit Name in the current form.

You must set the value of a formula variable with the set statement before you use it in an expression.

Formula variables retain their values only during the evaluation of the formula that contains them unless the formula variable has been exported with the export statement. Exported formula variables retain their values throughout the data entry session. Form does not automatically recalculate formulas that depend on an exported formula variable when that exported formula variable changes.

A formula variable is not the same as a field that has In Data File set to false (often called a form variable). A form variable is a field; it can be displayed on a form (if Invisible is set to no), the operator can enter data into it (if Entry Allowed is set to yes, it can be validated, a lookup, and can be accessed by a user edit routine. A formula variable, however, is only accessible from within a formula.

You should not use the following reserved words as variable names

Table 6-2: Reserved Words                               

boolean exit real strlen                                   

character export result strmid                             

date format return strright                                

delta if round test                                        

else integer set time                                      

elseif long short to                                       

endif match string total                                   

endwhile money strleft while