# eval modifier

The eval modifier performs the operation specified in the
 expression on the specified Attribute-Defining-Items. The expression performed is limited to
 A-Correlatives (concatenation, addition, subtraction, multiplication and division
 (`:`, `+`, `-`, `*`,
 `/`)).

## Syntax

```
eval "expression"
```

## Parameter(s)

| expression | Specifies the arithmetic operation to perform on the specified Attribute-Defining-Items. The specified expression must be enclosed in double-quotes. The oconvs() and trans() functions can be employed within the expression. See oconvs() and trans() Functions below. Parentheses are allowed in the expression. For example: ```
list inventory eval "(((PRICE - COST)/COST) * 100)"
``` |
| --- | --- |

 CAUTION:
 If the eval modifier is used with an Attribute-Defining-Item
 that contains any of the operators (below) in the name, the
 Attribute-Defining-Item will not be processed correctly.

- * (multiplication)

- / (division)

- + (addition)

- - (subtraction)

- : (concatenation)

## oconvs() and trans() Functions

The oconvs() and trans() functions can be
 employed within the specified *expression* to implement
 conversions and translates. Note that oconvs() is used instead of
 the oconv() function. The oconv() function is
 not supported for use within an eval expression. The
 oconvs() and trans() functions are only
 allowed within an eval expression.

## Syntax for oconvs()

```
oconvs(expression,&#39; conversion-code&#39;)
```

## Parameter(s)

| expression | The expression can be composed of any of the following: Numeric literals (not surrounded by quotes). Parentheses. ADI references. Any of the these operators: * (multiplication), / (division), + (addition), - (subtraction), : (concatenation). A trans() expression. Another oconvs() expression. |
| --- | --- |
| 'conversion-code' | The processing code. It must be surrounded by single-quotes. |

## Syntax for trans()

```
trans(&#39; filename&#39;, source-adi, translate-adi|amc,&#39; control-code&#39;)
```

## Parameter(s)

| 'filename' | The name of the translate file. It must be surrounded by single-quotes. |
| --- | --- |
| source-adi | The ADI that references the value to be translated. |
| translate-adi | An ADI in the dict of the translate file that references the resulting translate value. |
| amc | The attribute number of the item in the translate file that contains the resulting translate value. |
| 'control-code' | One of the subcodes of the t (Translate) processing code. It must be surrounded by single-quotes. See t (translate) processing code. |

 Recursion is supported for both the trans() and
 oconvs() functions. For example:

```
list myfile eval "trans(&#39;subject&#39;,trans(&#39;cr&#39;,course.id,short.title,&#39;x&#39;),
short.description,&#39;x&#39;)"
```

```
list myfile eval "oconvs(trans(&#39;cr&#39;,course.id,short.title,&#39;x&#39;),&#39;mcu&#39;)"
```

## Example(s)

The example below illustrated generating three columns: `price`,
 `cost` and `"price * cost"`.
 `price` and `cost` are Attribute-Defining-Items in
 the dict of the inventory file. The data in the `"price * cost"`
 column will be the product of the data in the previous two columns.

```
list inventory price cost eval "price * cost"
```

 The example below illustrates generating a column with the `"mr2"`
 conversion applied to the output of `"price * cost"`.

```
list inventory eval "oconvs(Price * cost,&#39;mr2&#39;)"
```

 The example below illustrates generating a column containing the
 `course.id`, and a second column containing a translate of the
 `course.id` through the `cr` file, where
 `short.title` is an Attribute-Defining-Item in the dict of the
 `cr` file. It specifies which attribute of the
 `cr` item contains the output text. The `'x'` is
 the standard translate parameter that specifies what to return if there is no
 value.

```
:list fcorr course.id eval "trans(&#39;cr&#39;,course.id,short.title,&#39;x&#39;)"
Page 1 fcorr 11:28:26 19 Aug 2009

fcorr..... course.id. trans(&#39;cr&#39;,course.id,short.title,&#39;x&#39;)

593910 2 writin
 1 readin
 3 rithmetic
[405] 1 items listed out of 1 items.
```

 The example below illustrates the `cr` items and `dict cr short.title` definition referenced in the example above.

```

:ct cr :ct dict cr short.title
 3 short.title
001 rithmetic 001 a
 1 002 1
001 readin 003
 2 004
001 writin 005
 006
 007
 008
 009 1
 010 10
```

## See also

- [fmt modifier](https://d3codex.com/access/fmt-modifier/)
- [oconv() function](https://d3codex.com/pickbasic-flashbasic/oconv-function/)
- [t (translate) processing code](https://d3codex.com/processingcodes/t-translate-processing-code/)

---
Source: https://d3codex.com/access/eval-modifier/ - part of the D3Codex reference.
