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)"

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,'conversion-code')

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('filename',source-adi,translate-adi | amc,'control-code')

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('subject',trans('cr',course.id,short.title,'x'),short.description,'x')"

 

list myfile eval "oconvs(trans('cr',course.id,short.title,'x'),'mcu')"

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,'mr2')"

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('cr',course.id,short.title,'x')"

Page   1                       fcorr  11:28:26 19 Aug 2009

 

 

 

fcorr..... course.id. trans('cr',course.id,short.title,'x')

 

 

 

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

    3

001 rithmetic

    1

001 readin

    2

001 writin

:ct dict cr short.title

    short.title

001 a

002 1

003

004

005

006

007

008

009 l

010 10

See Also

fmt Modifier, oconv() Function, t (Translate) Processing Code