# Formulas

A formula can be a simple pv, or an = followed by an expression. The expression allows to combine readings from multiple pvs.

## Simple pvs

Any string of text that does not start with = or ' is considered a pv:

    mypv123    : the pv called "mypv123"
    mypv+123   : the pv called "mypv+123"
    123        : the pv called "123"

Pvs can also be expressed in single quotes:

    'mypv123'  : the pv called "mypv123"
    'mypv+123' : the pv called "mypv+123"
    '123'      : the pv called "123"

## Formulas

Any string of text that starts with = must be followed by and expression.

Pvs in expressions must be single quoted:

    ='mypv123'  : the pv called "mypv123"
    ='mypv+123' : the pv called "mypv+123"
    ='123'      : the pv called "123"

Escaped text is supported within the single quotes with the same definitions as in Java. For example \n for new line, \" for double quotes, \' for single quotes and so on.

Expressions can contain numeric and string constants. Their definition matches Java.

    ="Some text" : a constant string
    =123         : the constant integer 123
    =3.14        : the constant double 3.14
    =1e5         : the constant double 100,000 in exponential notation

Expressions can be combined with operators and functions.

    =1000 * 'mypv' + 300 : the value from a pv called "mypv" multiplied by 1,000 and summed to 300
    =log('mypv')         : the logarithm of the pv called "mypv"
    =arrayOf(1,2,3,4,5)  : an array containing the first 5 integers

## Reference in Control System Studio

Since operators and functions can be added dynamically, we can't provide a full list here. In Control System Studio you can consult the Formula Function browser (CSS -> Debugging -> Formula Function)