Previous Topic: Server Procedure StructureNext Topic: GUI Event Processing


Control Structure

Control is passed and results received through event handlers, commands, exit states, flows, remote uses, and so on.

The following illustration provides an example of a task definition.

Example of a Task Definition

In this example, a design decision was made to use a separate client procedure and its primary window to present the customer detail. The alternative was to have an additional dialog box in the list customer client procedure. This decision was made to keep the amount of information about each customer returning from the customer server to the list customer window to a minimum since it is not necessary. Only when a new customer is added, an exiting customer is updated, or all data about a single customer need to be displayed will the detailed window be used. This choice significantly changes the logic.

It is very helpful if an organization decides on standards for common tasks such as this example. Standards ensure ease of maintenance during and after the development cycle by ensuring consistency of approach. There are user interface standards.

The following illustration and its key provide an example of the control structure. This example illustrates point by point, how control is passed and results are received through event handlers, commands, exit states, flows, and remote uses.

Control Structure Example

Control Structure Example 2

The steps in the next table lead you through the design shown in the illustration. Specific names of objects on the figure are shown in italics in the table.

Step

Action

1

The starting state for this example is that there has been a Display First flow to the List Customer window.
Even though the procedure is Display First, the open window event will execute.
The open window event sets the command to openlist and executes the remote use of the customer server procedure.

Note: You can design this into the event handler such that each time the event is executed the command will be set. That is why you do not see any logic to set the command in the event handler.

2

Control is passed from the customer list client procedure to the customer server procedure via the window and server managers.

3

The customer server procedure processes the request of the customer list client procedure by executing the case of command.
Since the open window event in the customer list client procedure sets the command to openlist, an action block is used to read and return the list of customers.

Note: The detail of the logic of the action block is not included, nor is the view matching from the server procedure. If there were any problems while trying to read the list of customers, an exit state would have been set.

4

Since a remote use statement was used for the procedure interaction, and there is logic after the remote use statement, the control passes back to the OPEN event via the window manager.
The window manager first checks to see if the exit state had changed to a value that will cause a flow.
If the exit state has not been changed to a value that would cause a flow, it is checked for having a message and the message type is informational, warning, or error. If the message type is any of these three values, a dialog box with the message will be presented to the user.
For this example, there were no errors.
The case of exit state logic in the OPEN event is then executed.
Since there were no errors, the control passes to the user via the window.

5

The user is presented with the window containing a list of customers.
The user selects one row (customer) from the list box.

6

The user clicks on either the edit or update menu items or the update from the tool bar.
This passes control to the menu update clicked event handler.

7

The menu update clicked event moves the selected row to the export view and sets the exit state to link to detail customer.
This causes a flow to the detail customer client procedure.

8

Control is passed to the detail customer client procedure.
This client procedure is Display First, flowed to on the link to detail customer exit state, and contains a view match of the selected customer.
Since it contains an open window event, this event will be executed first.

9

The open window event sets the command to opendtl and executes the remote use of the customer server procedure.

Note: The command opendtl was included at design time. There is no need for logic to set the command.

10

Control is passed from the customer detail client procedure to the customer server procedure via the window and server managers.

11

The customer server procedure processes the request of the customer detail client procedure by executing the case of command.
Since the open window event in the customer detail client procedure set the command to opendtl, an action block is used to read and return all of the information of a the selected customer.

Note: The logic detail of the action block is not included, nor is the view matching from the server procedure. If there were any problems while trying to read the list of customers, an exit state would have been set.

12

Since a remote use statement was used for the procedure interaction, and there is logic after the remote use statement, control passes back to the OPEN event via the window manager.
The window manager first checks to see if the exit state had changed to a value that will cause a flow.
If the exit state has not been changed to a value that would cause a flow, it is checked for having a message and the message type is informational, warning, or error. If the message type is any of these three values then a dialog box with the message will be presented to the user.
For this example, there were no errors.
The case of exit state logic in the OPEN event is then executed.
Since there were no errors, the control is passed to the user via the window.

13

The user is presented with the window containing the detail of the customer previously selected from the list customers.
The user modifies some information about the customer.

14

The user clicks on either the edit or update menu items or the update from the toolbar.
This passes control to the menu update clicked event handler in the detail customer client procedure.

15

The menu update clicked event automatically moves the import view to the export view (you do not have to put this logic in the event handler) and sets the command to update.
The menu update clicked event then executes the remote use statement to use the customer server procedure.

16

Control is passed to the customer server procedure.

17

The customer server procedure processes the request of the customer detail client procedure by executing the case of command.
Since the menu update clicked event in the customer detail client procedure set the command to update, an action block is used to read, update and return all of the information of a the selected customer.

Note: The detail of the logic of the action block is not included, nor is the view matching from the server procedure. If there were any problems while trying to read the list of customers, an exit state would have been set.

18

Since a remote use statement was used for the procedure interaction, and there is logic after the remote use statement, the control passes back to the menu update clicked event via the window manager.
The window manager first checks to see if the exit state changed to a value that will cause a flow.
If the exit state has not been changed to a value that would cause a flow, it is checked for having a message. The message type can be informational, warning, or error. If the message type is any of these three values, a dialog box with the message is presented to the user.

Note: For this example, there were no errors.

The case of exit state logic in the OPEN event is then executed.
Since there were no errors, control is passed to the user via the window.

19

The user is presented with the window containing the detail of the customer previously updated.

20

The user clicks the OK push button.
This passes control to the pb OK clicked event handler in the detail customer client procedure. This assumes that all of the information the user changed is presented properly.

21

The pb OK clicked event automatically moves the import view to the export view (you do not have to put this logic in the event handler).
The pb OK clicked event then sets the exit state to return.
Since this is the end of the pb OK clicked event, the window manager checks the status of the exit state.
Since the value of return causes a flow to the list customer client procedure, control is passed to list customer client procedure.

22

Control is passed to the list customer client procedure. This client procedure is Display First, flowed to on the return exit state, and contains a view match of the selected customer.
Since this procedure contains an open window event, this event is executed first.

More information:

Designing the Graphical User Interface