Constants

When a value is embedded in the formula itself, it is called a *constant*.

A numeric constant may be in fixed point format, like the numbers in this example (*2*, *90* and *0.0625*).

```
x+2
today() - 90
Total * 0.0625
```

A numeric constant may also be in floating point format, which consists of the mantissa followed by the letter e followed by the exponent. For example, suppose you needed to use this mathematical formula:

Here is how you would write this formula in Panorama.

```
x * 6.02e23
```

A formula may also contain *text constants*. A text constant is a series of characters surrounded by quotes. When writing a text constant you may choose from six different types of quotes: *Double Quotes, Single Quotes, Curly Braces, Smart Double Quotes, Smart Single Quotes,* and *Pipes*.

**Double Quotes** — This is the most common quoting method. The embedded text begins with a `"`

and ends with another `"`

.

```
"January"
```

A possible complication is if you want to include the `"`

character itself in the embedded text.

Suppose that you needed to use the text *The shim was 6" high* in a formula. Using double quotes around the constant will cause a grammar error (usually referred to as a syntax error), because Panorama will think that the embedded text ends after the second `"`

character, and it won’t know what to do with the text `high"`

.

```
"The shim was 6" high"
```

One solution is put two double quotes in a row, as shown in the example below. Panorama will convert these into a single quote and continue with the text constant.

```
"The shim was 6"" high"
```

Another solution is to use a different type of quote (see below).

Some other programming languages solve this problem by using an *escape* character, usually a backslash. Panorama does not use escape characters in text constants.

**Single Quote** — The embedded text begins with a `'`

and ends with another `'`

, like this.

```
'Tuesday'
```

You can use single quotes if you want to include a double quote in the embedded text.

```
'The shim was 6" high'
```

**Curly Brace** — The embedded text begins with a `{`

and ends with `}`

, like this.

```
{San Francisco}
```

**Smart Double Quote** — The embedded text begins with a `“`

and ends with `”`

, like this.

```
“Gothic”
```

**Smart Single Quote** — The embedded text begins with a `‘`

and ends with `’`

, like this.

```
‘Bohemian’
```

**Pipes** — The embedded text begins with one or more pipe symbols `|`

and ends with the same number of pipe symbols. For example, if the constant begins with `|||`

then it must end with `|||`

, if it begins with `|||||`

it must end with `|||||`

. Using the multiple pipes as quotes makes it easy to embed any other kind of character in the text constant:

```
|||last="Elliot" first="Suzette" address="892 Melody Lane"|||
```

You can even embed pipes within a piped constant, like this:

```
|||| language=javascript code=||alert("Hello World");|| ||||
```

As you can see pipe delimited constants are very handy for creating text constants that contain computer code.

Panorama has two built in numeric constants—pi and Euler’s constant. Use the Greek π symbol to access pi and ℇ for Euler’s constant. For example the area of a circle can be calculated with this formula.

```
π * radius^2
```

To create the π symbol press *Option-P*.

You can also use the pi() function instead of this special symbol.

```
pi() * radius^2
```

You can use eulersconstant( in place of ℇ, but in most cases it will be the exp( or log( function you really want.

Panorama has two built in text constants—¶ (Carriage Return) and¬ (Tab). For example a three-line address can be included in a formula like this.

```
"Suzette Elliot"+¶+892 Melody Lane"+¶+"Fullerton, CA 92831"
```

To create the ¶ symbol press Option-7. To create the ¬ symbol press Option-L.

Panorama also has functions to create special characters:

`cr() ☞ `*Carriage Return*
lf() ☞ *Line Feed*
crlf() ☞ *Carriage Return + Line Feed*
tab() ☞ *Tab*
vtab() ☞ *Vertical Tab*

There is also a general purpose function, chr(, that can be used to specify any Unicode character by its numeric value (see Characters and Unicode Values).

**Backslash Escape Sequences** — Some programming languages allow you to embed special characters in a text constant by using a special sequence starting with a backslash character. Panorama doesn’t allow this, the backslash is just another ordinary character. For example, in the C programming language you can embed a tab character with `\t`

, like this:

```
"First column\tSecond column"
```

In Panorama, you can’t embed a tab this way. Instead, you need to do something like this:

```
"First column"+tab()+"Second column"
```

Or like this:

```
"First column"+¬+"Second column"
```

**See Also**

- Arithmetic Formulas -- mathematical operators and functions.
- Characters and Unicode Values -- working with individual characters of text.
- convertvariablestoconstants -- converts all of the variables in a formula into constant values.
- Date Arithmetic Formulas -- performing calculations on dates, and converting between dates and text.
- Formula Workshop -- formula workshop wizard for testing and experimenting with formulas.
- formulacalc -- allows you to evaluate a formula that you were not able to code into the procedure when it was being written.
- formulafields( -- returns a list of fields used in a formula.
- formulaidentfiers( -- returns a list of identifiers (fields and variables) used in a formula.
- Formulas -- basics of formulas: components and grammar.
- formulavalue -- calculates the result of a formula. Usually this is done with an assignment statement (for example `x=2 * y` ), but the *formulavalue* statement gives you more flexibility. You can specify what database is to be used for the calculation (an assignment statement always uses the current database) and you can specify the formula using a variable, making it easy to change on the fly. This statement also gives you more control over how errors are handled.
- formulavariables( -- returns a list of variables used in a formula.
- Functions -- index of all functions available for use in Panorama formulas.
- Linking with Another Database -- techniques for relating multiple database files so that they work together.
- makemergeformula( -- builds a formula from an “auto-wrap" style merge template.
- Non Decimal Numbers -- working with numbers in alternative (non-decimal) bases, including binary, octal and hexadecimal.
- Numbers -- Working with numeric values in a formula, and converting between numbers and text.
- Operators -- index of all operators available for use in Panorama formulas.
- Quotes -- text constants embedded into a formula
- Statements -- index of all statements available for use in Panorama procedures.
- SuperDates -- date and time combined into a single value.
- Tag Parsing -- Panorama functions for working with text that contains data delimited by tags, including HTML.
- Text Formulas -- manipulating text with a formula (concatenation, extraction, rearranging, etc.)
- Time Arithmetic Formulas -- performing calculations on times, and converting between times and text.
- True/False Formulas -- logical boolean calculations.
- Using Fields in a Formula -- accessing database fields within a formula.
- Values -- the raw material that formulas work with -- numbers and text.
- Variables -- storing and retrieving individual items of data, not part of a database.

**History**

Version | Status | Notes |

10.0 | No Change | Carried over from Panorama 6.0 |