formulavariables(

formulavariables(

DATABASE

, FORMULA

)
The** formulavariables( **function returns a list of variables used in a formula.

**Parameters**

This function has two parameters:

** database** – the database the formula is associated with. If this is omitted or is

`""`

, the current database is assumed.** formula** – is the formula to be analyzed. If the formula is specified inline in the function itself, it must be quoted (see Quotes). Otherwise, you can pre-store the formula in a field or variable.

**Description**

The function returns a list of identifiers (fields and variables) used in a formula. The list is returned as a carriage return delimited text array.

For example,

```
formulavariables({alpha+cr()+bravo+sqr(Price)+upper(Name)})
```

will return the two variables that appear in this formula:

```
alpha
bravo
```

Note that this function doesn’t check to see if the variables actually exist. It simply analyzes the text of the formula to produce the list. Here is one way you could check the list for undefined variables.

```
let items = formulavariables({alpha+cr()+bravo+sqr(Price)+upper(Name)})
looparray items,cr(),item
let itemtype = catcherror("",datatype(item))
if itemtype = ""
message item+" does not exist."
endif
endloop
```

If the formula is associated with a different database (not the current database), you must explictly specify the database, like this.

```
formulavariables("Mailing List",{alpha+cr()+bravo+sqr(Price)+upper(Name)})
```

Note: You may wonder why the function needs to know the name of the database, since it is returning a list of variables, not fields. It needs this because it starts by getting a list of all identifiers in the formula (see formulaidentifiers(), and then removes the fields from the list.

**See Also**

- formulafields( -- returns a list of fields used in a formula.
- formulaidentfiers( -- returns a list of identifiers (fields and variables) used in a formula.
- formulastrings( -- returns a data array of strings (text constants) used in a formula.
- formulavalue( -- calculates the result of a formula based on data in the current record of any open database. This is similar to the fieldvalue( function, but allows any formula to be used, rather than just a single field.

**History**

Version | Status | Notes |

10.2 | New | Carried over from Panorama 6.0 |