Progress
AppBuilder
Developer’s Guide


Creating Calculated Fields

Very often, when creating applications, you will want to present a field to the user that is the result of some transformation applied to one or more other fields. Current value of inventory is one possible case, and invoice line-item total is another. The number of such potential uses is large.

Column Editor allows you to create such calculated fields in a straightforward way. To create a calculated field, follow these steps from the Column Editor’s dialog box:

  1. Click the Calculated Fields button. The dialog box opens:
  2. Compose the expression whose result will appear in the field. You can compose by typing directly into the field, by double-clicking on tokens (Fields, Functions, Operators), or by some combination of these two methods. The expression can be of any complexity. Choose OK when the expression is complete. The dialog box closes.
  3. The newly defined field appears in the list of fields with the default identifier CALC, a default type of CHARACTER x(8), and no label. Change the identifier to one more meaningful in the context of your application. Add a label, if appropriate.
  4. Change the data type and format, if necessary, to reflect the nature of the data. For example, if the expression yields a floating-point result, change the data type to DECIMAL and the format string to one that portrays DECIMAL values.
  5. If appropriate, choose Advanced and enter a Help string for this field.
  6. Use the Move Up/Down buttons to put the new field into the correct relationship to the other fields that will display.
NOTE: Calculated fields are created in a not-updatable state. Although you can set them to be updatable, in general you should not: a calculated field is a scratch field, and is undefined in the context of the database. It can be easy to forget this. If you do choose to make a calculated field updatable, you must write the code yourself that will interpret any changes that a user makes.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095