Data Screen Processing Logic [ HP ALLBASE/4GL Developer Reference Manual Vol. 1 ] MPE/iX 5.0 Documentation
HP ALLBASE/4GL Developer Reference Manual Vol. 1
Data Screen Processing Logic
The HP ALLBASE/4GL screen processing logic controls:
* Information display on the screen.
* Data acceptance from fields on the screen.
* Execution of screen field functions.
* Movement of data to and from the screen field buffers and other
data fields within HP ALLBASE/4GL.
* The sequence of screen field processing.
The following subsections describe the screen field processing sequence,
movement of data to and from screens, and data validation performed by HP
ALLBASE/4GL.
Screen Buffers
The screen processor maintains an internal data buffer for each field on
a data screen while the screen is being displayed. The attributes you
define for the field in the dictionary field specification, or the
attributes you enter on the screen fields detail screen define the
characteristics of each screen field data buffer.
HP ALLBASE/4GL moves data between the screen field buffers and the data
movement fields defined for each screen field during the screen
processing sequence.
HP ALLBASE/4GL clears the screen field buffers at the start of a process,
and when a SCREEN command is executed. The contents of the screen field
buffers remain available to commands in the current logic block until a
subsequent SCREEN command is executed.
Data Movement Fields
The screen field detail screen allows you to define a number of data
movement fields for each screen field. The data movement fields for each
screen field are:
* The primary data movement field.
* The default data movement field.
* Up to three other data movement fields.
Figure 6-1 shows the relationship between a screen field, the screen
field buffer, and the data movement fields.
Figure 6-1. Screen Field Buffers
For any screen field, the primary data movement field and the default
data movement field are mutually exclusive. You cannot define both a
primary data movement field and a default data movement field for the
same screen field.
Primary Data Movement File.
The screen processor moves the contents of the primary data movement
field to the screen buffer at the start of the processing sequence for
the field. For input fields, the screen processor moves data from the
screen field buffer to the primary data movement field at the end of the
processing sequence for the screen field.
The primary data movement field can be any of the following:
* File record field.
* Work area field.
* Screen field.
* Scratch-pad field.
* Variable.
Default Data Movement Files.
The default data movement field allows you to define a default entry for
a field that does not have a primary data movement field.
If the screen field buffer is empty or only contains pad characters at
the start of the processing sequence for a field, the screen processor
moves the contents of the default data movement field into the screen
buffer. If the screen field buffer already contains data, the default
data movement field is not used. You can only define a default data
movement field if you haven't defined a primary data movement field for
the screen field. The screen processor cannot move data back into the
default data movement field.
The default data movement field can be any of the following:
* Constant (numeric or alphanumeric).
* File record field reference.
* Work area field reference.
* Screen field reference.
* Scratch-pad field reference.
* Variable or calculated item.
Other Data Movement Fields.
For input fields, HP ALLBASE/4GL moves data from the screen buffer to the
other data movement fields when the screen field processing finishes and
the input data has been validated as correct. The screen processor
cannot move data from the other data movement fields to the screen
buffer. The other data movement fields can be any of the field types
specified for the primary data movement field.
Screen Field Functions
The screen field detail screen allows you to associate an HP ALLBASE/4GL
function with each screen field. You can specify that the function is
executed at the following times:
* After data has been moved from the primary or default data
movement field to the screen buffer, but before the contents of
the screen buffer are displayed on the screen. That is, a Prior
function. (Input and display fields.)
* After data has been accepted from the screen and moved to the
screen buffer. That is, an After function. (Input fields only.)
* Both before data display and after data acceptance. That is, a
Both function. (Input fields only.)
You can also specify that the function is executed when the contents of
the field are displayed by the SHOW command.
By testing the status of the switches *ENTERED and *SHOWING in the
function, you can determine if HP ALLBASE/4GL is executing the function
before the user enters data in the field, after data entry, or as the
result of a SHOW command.
The function associated with a field can use any of the logic commands.
(Some of the logic commands may terminate the current screen. For
example, if the function associated with a screen field executes a
process with a PROCEED command or displays a further screen with a SCREEN
command, the current screen will be terminated.)
Switches and Communication Area Fields
The HP ALLBASE/4GL screen and field processing logic uses several
communication area fields and switches. The function associated with a
screen field can use or alter the contents of these communication area
fields, or test the status of any of these switches.
Communication Area Fields.
The communication area fields used during screen processing are:
* *SCREEN This alphanumeric communication area field contains the
name of the current screen.
* *FIELDNO This alterable communication area field holds the number
of the current screen field. You can alter the value in this
field with the MOVE command in a function.
* *NEWTIE This alterable communication area field holds the number
of the next screen field to be processed. Moving a value into
*NEWTIE has the same effect as using the TIE logic command to
specify the next field to be processed.
* *PREVFLD This read-only communication area field contains the
number of the last screen field to be successfully committed. A
function associated with a screen field can test the value in
*PREVFLD to determine which screen field the user accessed before
entering the current field. HP ALLBASE/4GL sets the value in this
field to 1 at the start of a screen.
Switches.
The switches used by the screen processing logic are:
* *ENTERED This switch indicates whether the user has entered data
into a screen field. HP ALLBASE/4GL sets *ENTERED off before the
prior function for the field is executed. *ENTERED is set on
after the user has entered data into the field and the data has
been accepted according to the edit code, minimum number of
characters for the field, and validation table or range for the
field.
* *ENDFIELD This switch indicates whether the input processing for
the current field continues or is terminated. If a function
called from a function key sets *ENDFIELD on, HP ALLBASE/4GL
terminates the input field processing for the current field when
the function exits.
You can set *ENDFIELD on in a function called from a function key
or a prior function on an input field. You can also use a TIE
command in the function to specify the next field on the screen to
be processed. If you do set *ENDFIELD on, and the user has
changed the entry in the current screen field, HP ALLBASE/4GL
restores the original contents of the field before it starts
processing the next field on the screen, or the field specified by
the TIE command.
You can also set *ENDFIELD on in a function called from the
function key, or in a second function called from that function.
* *SHOWING This switch indicates whether the contents of the field
are being displayed under the control of a logic SHOW command.
The switch is set on when the SHOW command is active, and restored
to its previous condition at the end of the SHOW command.
Screen Processing Sequence
HP ALLBASE/4GL processes screens at two different levels. These are the
field level, and the screen level.
A number of factors influence the sequence of actions initiated by the
screen and field processing logic. These factors are:
* The SCREEN logic command and the D- action from a menu, decision
table, or function key.
* The function associated with each screen field.
* Field and screen commit actions initiated by the user.
* The TIE logic command.
When HP ALLBASE/4GL starts processing a data screen, the flow of control
in the application is determined by the screen and the logic associated
with the screen. Displaying a screen terminates the current screen if
one is active, and clears the screen field buffers. The data screen
remains active until the user or the logic associated with the screen
initiates a screen commit action.
When a screen is committed, HP ALLBASE/4GL resumes running the
application in one of three possible ways, depending how the screen was
invoked.
* If the screen was displayed by a SCREEN command in a logic block,
control returns to the command immediately following the SCREEN
command.
* If the screen was displayed directly from a menu, control returns
to the menu.
* If you displayed the screen from a SCREEN command in a function on
a field on another screen, or from a function called from a
function key on another screen, HP ALLBASE/4GL firstly returns to
the function and executes the remaining commands in the function
logic block. Since the original screen is terminated when the
second screen is displayed, control then returns to the logic
block or menu that displayed the original screen.
NOTE In general, you should avoid calling further data screens while a
data screen is active.
If you need to modify the current screen, use a window in
preference to calling a further screen.
The logic SCREEN command or the D- action initiates processing at the
screen level. Figure 6-2 shows the screen processing logic in
diagrammatic form.
Once HP ALLBASE/4GL starts processing a screen, processing continues on a
field by field basis.
Figure 6-2. Data Screen Processing Logic
Screen and Field Commit Actions
Screen and field commit actions initiated by the user control the screen
processing sequence.
A field commit action is any action (such as pressing Return or the Tab
key) that moves the cursor off the current field. Field commit actions
by the user control data acceptance and validation on a field by field
basis.
A screen commit action is initiated by the internal I-COMMIT routine.
This action is usually initiated from a function key on the screen.
(Refer to Function Keys Screen, page 6-33.) A screen commit action can
also be initiated by an EXIT *COMMIT logic command in an after function
on a screen field, or in a function called from a function key.
The screen commit action terminates processing of the screen.
Field Display Logic
When HP ALLBASE/4GL processes a screen, it immediately executes the field
display logic for the first numbered field on the screen. Figure 6-3
shows the field display logic.
HP ALLBASE/4GL first checks for the existence of a primary data movement
field. If this field exists, the screen processor moves its contents to
the screen field buffer and then performs any necessary justification and
filling with the pad character. The screen processing logic only uses
the contents of the default data movement field if there is no primary
data movement field defined for the screen field and the screen field
buffer is empty, or contains only pad characters.
After performing the data movement, HP ALLBASE/4GL sets *ENTERED off, and
then executes the prior function if one is defined for the field.
After the prior function has been executed, the screen processor displays
the contents of the screen buffer on the screen.
At this point, the screen processor tests the contents of *FIELDNO. (See
Figure 6-2, step 2.) If the prior function has changed the value in
*FIELDNO, HP ALLBASE/4GL immediately starts processing the field
identified by the new value in *FIELDNO. Changing *FIELDNO in the prior
function allows you to conditionally bypass the field or a group of
fields.
If *FIELDNO has not been changed, HP ALLBASE/4GL checks whether the field
is a display-only field or an input field (step 3 in Figure 6-2).
For display-only fields, HP ALLBASE/4GL then processes the next field in
the sequence for the screen unless you have changed the value in *NEWTIE,
or used the TIE logic command to specify the next field to be processed.
(See Figure 6-2 step 6.) The processing of data input fields is
described below.
Figure 6-3. Field Display Logic
Input Field Logic
Before input processing for an input field starts, HP ALLBASE/4GL tests
the status of the switch *ENDFIELD. If *ENDFIELD is on, the contents of
the field are restored to the state that existed at the end of display
processing for the field. Display processing then starts for the next
screen field. You can only set the switch *ENDFIELD on in a function
called from a function key or a prior function on an input field. This
function can contain a TIE command to specify the number of the next
field to be processed.
If *ENDFIELD is off, HP ALLBASE/4GL starts the input processing for the
field.
Figure 6-4. Input Field Logic
Figure 6-4 shows the input field processing logic. This part of the
screen processing logic corresponds to steps 4 and 5 in Figure 6-2.
Input field processing starts when the user initiates a commit action for
the field. A field commit action is any action that moves the cursor
away from the field, such as pressing the Return key or the Tab key. HP
ALLBASE/4GL also initiates a field commit action if the user presses the
Commit Data function key and the contents of the current field have not
been committed. In this case, HP ALLBASE/4GL processes the current field
and then terminates the screen.
The current field is also committed if a function called from a function
key changes the value of *FIELDNO. In this case, HP ALLBASE/4GL executes
the function called from the function key, and then immediately commits
the current screen field. After the field commit, HP ALLBASE/4GL
processes the field specified by the new value of *FIELDNO.
After a commit action, HP ALLBASE/4GL checks if the action represents a
new commit for the field. A commit action is considered to be a new
commit if:
* The data in the field has changed since the last commit action for
the field,
or
* A different numbered input field has been processed since the last
commit action for this field.
If the current commit for the field is not a new commit action,
processing only proceeds if the previous commit action for the field
generated an error.
When HP ALLBASE/4GL accepts a field commit, it tests the data against the
edit code, minimum and maximum number of characters, number of decimal
places, and validation range or table (if defined) for the field. If no
error is detected, HP ALLBASE/4GL sets *ENTERED on and executes the after
function for the field if one is specified.
Error Processing.
If the user's input doesn't satisfy the edit code, number of decimal
places, or minimum number of characters for the field, HP ALLBASE/4GL
displays an internally defined error message. In this case, the cursor
remains on the current field to allow the user to reenter the data.
If the user's input does not fall within a validation range or table
associated with the field, HP ALLBASE/4GL displays the message associated
with the table or range. The system actions depend on the message type.
If the message is an error type message, the cursor remains on the
current field to allow the user to reenter data. For other message
types, HP ALLBASE/4GL displays the message, but the cursor does not
remain on the current field. If the message is an abort type message,
the application terminates.
If you haven't defined a message for a validation table or range
associated with the field, and the user's input doesn't fall within the
table or range, the screen processor displays a system defined error
message. In this case, the cursor remains on the current field.
After Entry Functions.
HP ALLBASE/4GL executes the after function after the automatic data
validation has been completed, and data has been accepted into the screen
field buffer and the switch *ENTERED has been set on. Note however, that
HP ALLBASE/4GL has not yet moved the screen field data to the data
movement fields.
You can use the after function to perform additional validation of the
input data. You can also use the after function to move a value to
*FIELDNO.
If the function displays an error type message as the result of any of
the additional validation tests, HP ALLBASE/4GL tests the value in
*FIELDNO. If the after entry function has not changed the value in
*FIELDNO, the cursor remains on the current field to allow the user to
correct the data.
If the function has changed *FIELDNO, HP ALLBASE/4GL restores the
contents of the field to the state that existed at the end of the display
processing for the field, and then starts processing the field identified
by the contents of *FIELDNO.
Typically, you would only change the value of *FIELDNO in an after
function if you wanted to return the user to an earlier screen field as
the result of an error detected during data validation in the function.
If no errors are generated in the after function, the screen processor
moves the contents of the screen buffer to the primary and other data
movement fields (if defined). Screen processing then continues at the
next field in the tabbing sequence for the screen unless you have moved a
value to *FIELDNO in the after function, or used the TIE logic command to
change the value in *NEWTIE. (See Figure 6-2, steps 5 and 6.) If you
have changed either of these values, processing continues at the field
identified by the value in *FIELDNO or *NEWTIE.
NOTE If you want to continue processing at a field other than the next
field in the screen sequence, use the TIE command in preference to
changing the value of *FIELDNO in the after function. The TIE
command allows you to reference the next field by name rather than
by field number.
Data Validation Summary
The following paragraphs summarize the data validation that is performed
by HP ALLBASE/4GL during screen field processing.
Automatic Data Validation.
HP ALLBASE/4GL performs automatic data validation on user input after the
user commits a field. This validation occurs before the data is accepted
into the screen field buffer, and before the switch *ENTERED is set on.
The automatic validation tests are shown in the following table.
-----------------------------------------------------------------------------------
| | |
| Test | Action on Failure |
| | |
-----------------------------------------------------------------------------------
| | |
| Edit code | System defined error message |
| | |
| Number of decimal places | System defined error message |
| | |
| Number of characters >= minimum | System defined error message |
| | |
- - -
| Validation range | Developer defined message, or system |
| | defined default error message |
| | |
| Validation table | Developer defined message, or system |
| | defined default error message |
| | |
-----------------------------------------------------------------------------------
Additional Validation.
HP ALLBASE/4GL allows you to perform additional data validation in the
after function on an input field. The function can perform any
validation tests you require, and display a message if the data fails
validation. The system action depends on the message type code.
Automatic Data Movement
The following table summarizes the automatic data movement that HP
ALLBASE/4GL performs during screen field processing.
-------------------------------------------------------------
| | |
| Timing | Data Movement |
| | |
-------------------------------------------------------------
| | |
| On display | Screen field buffer <= Primary movement field
| (all fields) | |
| | or |
| | |
| | Screen field buffer <= Default movement field
| | (If screen field buffer is empty) |
| | |
-------------------------------------------------------------
| | |
| After Commit | Screen field buffer => Primary movement field
| (input fields) |
| | and |
| | Screen field buffer => Other movement fields
| | (If defined) |
| | |
-------------------------------------------------------------
Commit Data Actions
The I-COMMIT internal routine terminates all current screen processing.
Typically you would use a Commit Data function key on each application
data screen to invoke the I-COMMIT internal routine when the user has
finished entering data. Refer to the function keys screen on page 6-33
for further details.
You can also force a screen commit by using the *COMMIT argument with the
logic EXIT command in an after function on an input field, or in a
function called from a function key. (Refer to chapter 12, Logic
Commands.)
HP ALLBASE/4GL executes the I-COMMIT internal routine immediately if the
current screen field has been processed. If the current field has not
been processed, HP ALLBASE/4GL processes this field and then executes the
I-COMMIT internal routine.
Following the I-COMMIT internal routine, HP ALLBASE/4GL resumes running
the application in one of three possible ways, depending on how the
screen was displayed.
* If the screen was displayed by a SCREEN command in a logic block,
control returns to the command immediately following the SCREEN
command.
* If the screen was displayed directly from a menu, control returns
to the menu.
* If the screen was displayed by a SCREEN command in a function on a
field on another screen, or a function called from a function key
on another screen, HP ALLBASE/4GL firstly returns to the function
and executes the remaining commands in the function logic block.
Since the original screen is terminated when the second screen is
displayed, control returns to the logic block or menu that
displayed the original screen.
MPE/iX 5.0 Documentation