HP 3000 Manuals

Calculated Items Screen [ HP ALLBASE/4GL Developer Reference Manual Vol. 1 ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Reference Manual Vol. 1

Calculated Items Screen 

This screen allows you to define a calculated item.  A calculated item is
a variable that contains the result of an algebraic expression or a
function that is evaluated whenever the item is referenced.  Calculated
items exist in two forms, the simple form and the extended form.  HP
ALLBASE/4GL implements both forms of calculated item by executing a
function when the item is referenced.  The function assigns a value to
the calculated item.

In the simple form, you specify the expression to be evaluated as a
single algebraic equation using the CALC logic command.  In the extended
form, rather than specify an algebraic equation, you use a function with
the same name as the calculated item.  This function may perform any
processing that is normally permitted within a function.  The value of
the calculated item must be set explicitly within the function.  To
specify a calculated item in this form, you must first define the name
and attributes of the calculated item using this screen, and then use the
function details screen in the logic menu to define the details of the
function.  Chapter 11 describes HP ALLBASE/4GL functions.

Screen Image 

[]
Field Descriptions Item Name Enter the name of the calculated item (up to 16 characters). When you enter a new calculated item name, HP ALLBASE/4GL automatically creates a function with the same name. HP ALLBASE/4GL displays an error message if you enter a name which is already in use for a function. Length Enter the maximum length in characters of the value that can be assigned to the calculated item by the assigning function. Edit Code Enter a code defining the type of data that the calculated item may contain. The following table lists the available edit codes and their meanings. Code Meaning X Any printable character. A Alphabetic characters only (A to z, extended characters, or space). U Forced uppercase. Same as X edit code, but shifts all lowercase alphabetic characters to uppercase. K Alphanumeric characters only (A to z, 0 to 9, extended characters, and underscore). N Unsigned number (0 to 9, a period ".", or a comma ","). S Signed number. Same as N edit code, but may include + or -. Q Question. Y, y, N, or n only. Any characters beyond the first character in the field are ignored. D Date field. Must be eight characters long. The date may be either MM/DD/YY or DD/MM/YY (depending on the system-wide date format) where MM, DD, and YY represent the month, day, and year respectively. T Date field, defaulting to the current date. Number of Decimal Places Enter the maximum number of decimal places for the contents of the calculated item if the item is numeric (edit code N or S). Pad Character Enter a single character used to initialize the calculated item. HP ALLBASE/4GL sets every character of the item to the value of the pad character before calling the assigning function. CALC The value of a calculated item is assigned by a function HP ALLBASE/4GL creates for this purpose. The function may be either a simple function or an extended function. A simple function is one that contains only a single CALC command. To create a simple function, enter the details of the CALC command in this area of the screen. You don't need to use the command name CALC as part of this command expression. HP ALLBASE/4GL assumes the entry in this field is a CALC command, and displays the word CALC in a display only field the left of the command field. Refer to chapter 12 for details of the CALC command. An extended function either has more than one step, or consists of a single step that is not a CALC command. To define a calculated item using an extended function, leave the CALC field blank. You can then use the function detail screen in the logic menu to define the extended function. Note that HP ALLBASE/4GL automatically creates a function header using the name of the calculated item as the function name, and the description fields from this screen. Refer to chapter 11 for details of function header and function details screens. The assigning function or a function called from the assigning function may use the calculated item. Under these circumstances, the value in the calculated item is its existing value. The calculated item is not re-evaluated if it is used in the assigning function. Description Documentation fields. Enter a description of the calculated item for documentation purposes. HP ALLBASE/4GL automatically updates the date and time fields to show the date and time of the last modification. HP ALLBASE/4GL uses the description fields and the calculated item name to create the function header for the assigning function. Function Keys f1 Variable Cancels the current screen and displays the variables screen. f2 Function Details Cancels the current screen and displays the function details screen. f3 Numeric Constant Cancels the current screen and displays the numeric constants screen. f4 AlphaNum Constant Cancels the current screen and then displays the alphanumeric constants screen. Additional Information You cannot create a calculated item with the same name as a function that already exists. Values can only be assigned to a calculated item from within a function of the same name as the calculated item. Generating Calculated Items. When you press the Commit Data function key, HP ALLBASE/4GL generates the assigning function automatically. HP ALLBASE/4GL displays an error message if the function generate fails. Using Calculated Items. In general, you can use calculated items in the same way as you would use HP ALLBASE/4GL variables, provided you don't move data into the calculated item. If you do try to move data into a calculated item, the application aborts. Only the assigning function can move a value into a calculated item.


MPE/iX 5.0 Documentation