Progress
Results User’s Guide
for UNIX


Adding a Math Expression

This section explains how to add a math expression to determine the cost for each order line in a customer’s order. To do this, you define the math expression to multiply the number of units in each order line by the cost for each unit.

  1. Select Define.
  2. Since you have already defined files you plan to work with, the screen displays a list of options you can choose from to expand your report:

  3. Select Math Expressions.
  4. Results displays a list of operations:

    You can select any of these operations to create your math expression.

  5. Select Multiply.
  6. A window opens that lists all the numeric fields in the active files:

    Results prompts you to enter the first multiplier in your math expression. In this tutorial, you multiply the number of units on hand by the cost for each unit.

  7. Select the Qty field.
  8. The list of numeric fields you can pick appears again. The expression begins to build in the Expression window and Results prompts you to choose the next multiplier:

  9. Select the Price from Item database field.
  10. The Price field appears in the Expression window and Results prompts you to continue adding to this expression:

    If you select Yes, you can continue to add to the expression using any of the math operations (Add, Subtract, Multiply, Divide, or Raise to a Power) and Results automatically groups them with parentheses. In this tutorial, you will multiply these two selected fields.

  11. Select No.
  12. The screen clears to the Report layout window and another window, Formats and Labels, appears. Here you can redefine the default label and format information for the new numeric field created by the Math Expression:

    This window contains the following:

    • File—Displays as Numeric Expr, because it is a generated field (not contained in any database file).
    • Field—Displays the name which Results automatically assigns to the field you are creating. This field name will be in the list with the other field names once you add the new field.
    • Expression—Displays the math expression you just built. In this case, an ellipse
      (. . .) shows that Results truncated the expression to fit it in the window.
    • Type—Displays the data type of the field. In this case, the data is in decimal format.
    • Label—Displays the default text that appears above the column in the report. In this case it is Math Value. You can change this to a more descriptive name for your report.
    • Format—Shows the default display format. In this case, the format is ->>>>>>>9.99.
    • Next, you define a new label and a new format for this field. Leave the repeating value to the default no.

  13. Type Price/Line as the new label.
  14. Type >,>>>,>>9.99 as the new format:
  15. This format means that the field can have up to seven digits to the left of the decimal and two digits to the right. It will also display in a right-justified format. Results does the following to the fields format:

    • The greater than symbols (>) are space holders for digits. A blank space replaces the > if there is no digit in that position.
    • The comma (,) acts as a place holder. This character displays literally in the value.
    • The 9 is replaced by a digit from 0 to 9. A zero replaces the 9 if there is no digit in that position. Because two 9s follow the decimal point, Results displays only two digits after the decimal point.
    • The decimal point marks the location of the decimal point in the field. This character displays literally in the value.
    • NOTE: If Results is set to default to the European numeric format (using the European Numeric Format (-E) startup option), numbers on your screen appear in European numeric format. In European numeric format, a comma (,) marks the decimal location in fields and a period point (.) acts as a place holder. For example, with your format set for European display, the format >,>>>,>>9.99 appears as >.>>>.>>9,99. For more information about field formats and the -E startup option, see "Field Display Formats."

  16. Press GO or RETURN.
  17. The new field appears in the Report Layout window. Note that the report layout is too wide to display on the screen. Use the > and < keys to scroll to the left and right of the Report Layout window to see all the field format.

    The *n marker tells you that this is a numeric expression field. In this case, it is a math expression field:

  18. Run the report to your terminal.
  19. Again, use the > and < keys to scroll left and right across the page to see all the field values.

    There are a couple of things you can do to make this report easier to read and more meaningful. You can change the label and format of some of the fields so they fit within the screen. You can also hide repeating values so you do not see the customer name or order number more than once.

  20. Press END to return to the Report Layout window.

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