In the following example, the price per pound of a yacht is
computed as the price divided by the displacement. In this
case, both the PRICE and DISP fields are defined in the record
definition.
06 PRICE_PER_POUND
EDIT_STRING $$$,$$9.99
COMPUTED BY PRICE/DISP.
When the PRICE_PER_POUND field is used in a command or statement,
DEC DATATRIEVE divides the value of the record's PRICE field by
the value of its DISP field. The result of the computation is the
value of the PRICE_PER_POUND field.
In the following example, the discount price of a yacht is
computed. The amount of the discount varies with the price of
a yacht. The field PRICE is defined in the record definition for
YACHTS:
06 DISCOUNT_PRICE COMPUTED BY
CHOICE
PRICE LT 20000 THEN (PRICE * .9)
PRICE LT 30000 THEN (PRICE * .8)
PRICE LT 40000 THEN (PRICE * .7)
ELSE (PRICE * .6)
END_CHOICE
EDIT_STRING IS $$$,$$$.
When DISCOUNT_PRICE is used in a command or statement, DEC
DATATRIEVE evaluates each Boolean expression in order until one
evaluates to true. Then it performs the corresponding computation
on PRICE.
In the following example, the value of the SALESFORCE field is
derived from a dictionary or domain table named SALES_TABLE:
06 SALESFORCE
EDIT_STRING IS X(20)
COMPUTED BY MANUFACTURER VIA SALES_TABLE.
In this example, DEC DATATRIEVE uses the value of the
MANUFACTURER field in the current record to search the dictionary
or domain table SALES_TABLE for a matching code. If one is
found, DEC DATATRIEVE uses its translation as the value of the
SALESFORCE field.