HP 3000 Manuals

Modifying HP TurboIMAGE/iX Based Applications [ HP ALLBASE/4GL Developer Self-Paced Training Guide ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Self-Paced Training Guide

Modifying HP TurboIMAGE/iX Based Applications 

The modified product_proc process reads like this: 

 1 DM IMAGE *MODE *MODLOCK :D-traindb
 2 MODE *WRITE product
 3 MOVE C-no_record V-product_status
 4 SCREEN product_scrn
 5 IF V-mode = C-add THEN VISIT add_product
 6 IF V-mode = C-modify THEN VISIT modify_product
 7 IF V-mode = C-delete THEN VISIT delete_product
 8 IF *IOSTATUS <> "00000" & *IOSTATUS <> N-record_not_found
      THEN ENTER 11
 9 DM IMAGE *UNLOCK :D-traindb
10 ENTER 4
11 MESSAGE file_error
12 SCREEN main

The following paragraphs explain what each step in the process does.

Line 1                This step sets the database mode in which the
                      application accesses the traindb database.

Line 2                This step sets the HP ALLBASE/4GL access mode for
                      the product data set.

Line 3                This step initializes the value of the variable V- 
                      product_status when the screen is first displayed.

Line 4                This step displays the product_scrn data screen.
                      The same screen is used for each mode.  The setting
                      of the mode variable determines how the process
                      updates the files when the user commits the screen.

Lines 5, 6 and 7      The IF commands test the update mode, and then
                      invoke the appropriate file update function using
                      the VISIT command.

Line 8                Values of 00000 or 19111 in *IOSTATUS indicate that
                      all file transactions occurred without error, or
                      that the record could not be found.

                      If the file manager return status is neither of
                      these values, a file error has occurred during the
                      update functions.  In this case, control passes to
                      the error handling logic starting at step 11.

Line 9                This step releases any locks held by this process
                      on the traindb database.  Locks are set in the
                      functions called to add, modify, or delete
                      products.

Line 10               This step returns control to step 4 to display the
                      product_scrn screen again.

Line 11               Control only passes to this step if an error is
                      detected at step 6.  This step displays a message
                      to warn the user that an error has occurred and the
                      current product information may be corrupted.

Line 12               This step returns the user to the main menu.
                      Displaying a menu is one technique you can use to
                      recover from serious, but non-fatal error
                      conditions.  When HP ALLBASE/4GL displays a menu,
                      all current activity in the application ceases.
                      This means that the application returns to a known
                      condition.  To continue from the main menu, the
                      user must select a menu action.  Any actions that
                      can update data files initiate a process, so all
                      file record and screen buffers are cleared
                      automatically.  You don't need to release the DM
                      IMAGE *LOCK in this situation, because all HP
                      TurboIMAGE/iX locks are released automatically when
                      a process exits.

Modifying Logic Blocks 

This part of the lesson shows you how to use facilities that allow you to
modify logic blocks.  You use the same methods to modify processes and
functions. 

To insert a step: 

   1.  Call up the process details screen and follow these steps:

Action                    Explanation 

------------------------------------------------------------------------------

Enter product_proc        This displays the product_proc process in its
                          current state and places the cursor in the step
                          number field.

Enter 3                   The cursor moves to the action field.

Enter I                   This indicates that you want to insert a step
                          before step number 3.  The current steps move down
                          one line, and step 3 becomes blank.  Then the
                          cursor moves to the command field.

Enter MOVE                This displays an open window.  The MOVE command is
                          used to copy the contents of a field to another
                          field.

Enter C-no_record
V-product_status

To complete the window: 

The MOVE command is now complete.

   1.  Press the  Commit Data  function key to commit it.

       HP ALLBASE/4GL clears the window and displays the new command at
       step 3.  The cursor returns to the Step Number field and the step
       number is incremented to 4.

Step Number References.   

Read the last line of the process.  Before you inserted a new step, this
logic step was ENTER 3.  Now it is ENTER 4.

HP ALLBASE/4GL has automatically incremented the step number reference as
the SCREEN command has moved down from step 3 to step 4.  HP ALLBASE/4GL
updates step number references when you insert or delete lines from a
logic block.

Using the IF Window 

The next command that you need to insert is step 5.  This contains an IF
command.

To use the IF window: 

   1.  Insert a new step 5, and enter IF in the Command field.

       This displays the IF command window.  The fields on this window
       are explained in more detail below.

   2.  Enter the appropriate information for each field.

        Field                 Entry                         Explanation 

---------------------------------------------------------------------------------------

Condition 1                                 The first three fields of the IF window
                                            establish the first condition that the IF
                                            command tests.  In many cases it is the
                                            only condition.

Data Name 1           V-mode                The name of the object to be tested.  In
                                            this case, the command tests the variable
                                            mode, which contains one of the four update
                                            modes; add, modify, delete or review.

IF Test               =                     The test to be performed.  In this case the
                                            test is whether or not the content of the
                                            mode variable equals the value in the Data 
                                            Name 2 field.

Data Name 2           C-add                 Where an IF Test compares two operands with
                                            a relational operator such as "=", "<",
                                            ">", or "<>", you must enter the name of
                                            the second operand in this field.

                                            In this case, the mode variable will be set
                                            to the contents of the add alphanumeric
                                            constant if the user selected Add on the
                                            main menu.  The IF command tests to see
                                            whether this is the current value of
                                            V-mode.

          Table 7-0.  (cont.) 

        Field                 Entry                         Explanation 
---------------------------------------------------------------------------------------

AND/OR                Leave this field      The IF command can test two conditions and
                      blank.                combine the results using a logical AND or
                                            a logical OR connective.  The symbols & and
                                            | represent the AND and OR connectives
                                            respectively.

                                            When you leave this field blank, the cursor
                                            skips the next three fields.

THEN Statement        VISIT add_product     When you leave the AND/OR field blank and
                                            press Return, a THEN prompt appears.

                                            The cursor is placed in the field to the
                                            right of this prompt.  This is where you
                                            enter the commands to be performed when the
                                            test is resolved as true.  You can execute
                                            any command at this stage except IFLOOP,
                                            SELECT, or another IF statement.

                                            You can specify multiple commands by
                                            separating the commands with a semicolon.
                                            For example, you could enter a string of
                                            commands in this field like this:

                                            MESSAGE added_ok ; ENTER 10

ELSE Statement        Leave field blank.    After you enter the THEN statement, the
                                            window displays an ELSE prompt and
                                            positions the cursor in the field beside
                                            the prompt.  This is where you enter the
                                            commands to be performed if either test is
                                            resolved as false.  This entry follows the
                                            same format as the THEN statement.
                                            However, it is not a required field.  If
                                            you don't enter any ELSE commands, control
                                            passes to the next step in the process or
                                            function if the test is resolved as false.

To complete the window and continue: 

The IF command is now complete.

   1.  Press the  Commit Data  function key to commit it.

       HP ALLBASE/4GL clears the window and displays the new command at
       step 5.  The cursor returns to the Step Number field and the step
       number is incremented to 6.

   2.  Now insert steps 6 and 7, which are very similar to the step you
       just inserted.  These two steps also call up functions to update
       the product file.

       The steps are shown below.

6 IF V-mode = C-modify THEN VISIT modify_product
7 IF V-mode = C-delete THEN VISIT delete_product

At the moment, there are only three update functions available, and the
code is short and simple.  However, in later lessons, you will introduce
more functionality.  Instead of adding a lot of logic commands, you will
convert these decision logic lines into one logic command that calls a
decision table.  Decision tables allow you to define a series of actions
to be performed as the result of the outcome of a complex series of
conditional tests or questions.

Your process should now look like this:

 1 DM IMAGE MODE *MODLOCK :D-traindb
 2 MODE *WRITE
 3 MOVE C-no_record V-product_status
 4 SCREEN product_scrn
 5 IF V-mode = C-add THEN VISIT add_product
 6 IF V-mode = C-modify THEN VISIT modify_product
 7 IF V-mode = C-delete THEN VISIT delete_product
 8 FILE *WRITE product
 9 DM IMAGE *UNLOCK :D-traindb
10 ENTER 4

Continuing the Change.   

The next task is to insert a new step 8.  This step also uses the IF
command, but this time, two sets of conditions are tested. 

   1.  Insert step 8 now, using the following details for each field.

        Field                 Entry                         Explanation 

---------------------------------------------------------------------------------------

Command               IF

Data Name 1           *IOSTATUS             In this case, the command tests the HP
                                            ALLBASE/4GL communication field *IOSTATUS,
                                            which contains either zero, or the error
                                            message number returned by the HP
                                            ALLBASE/4GL data manager after an access to
                                            an application data file.

IF Test               <>

Data Name 2           "00000"               The value "00000" will be the content of
                                            *IOSTATUS if no file errors have occured.
                                            The IF command tests to see whether this is
                                            the current value of *IOSTATUS.

AND/OR                &                     This represents AND.

                                            * Enter the following information in the
                                            appropriate fields:

Condition 2                                 The next three fields establish a second
                                            condition that the IF command tests.

Data Name 1           IOSTATUS

IF Test               <>

Data Name 2           N-record_not_found

THEN Statement        ENTER 11              When you complete the condition fields and
                                            press Return, a THEN prompt appears.  Enter
                                            the command shown.

To complete the window: 

The IF command is now complete.

   1.  Press the  Commit Data  function key to commit it.

Adding Commands.   

The following commands can be added to the end of the logic block at
steps 12 and 13, respectively.

   1.  Add the commands as shown below.

       12 MESSAGE file_error
       13 SCREEN main

       Both of these logic commands use open windows for you to enter the
       logic command details.

Deleting a Step.   

You can now delete an existing step.  We wish to delete the FILE step.

   1.  Make sure the cursor is at the Step Number field, and follow these
       steps.

Action                    Explanation 

------------------------------------------------------------------------------

Enter 9                   The cursor moves to the action field.

Enter D                   This indicates that you wish to delete the current
                          step.

Press Return              Step 9 is deleted from the logic block, and the
                          steps below it are moved up.

       A message is then displayed at the bottom of the screen, prompting
       you to press the  Commit Data  key to make the deletion permanent.
       The D action blanks out the step from the screen.  However, the
       step is not actually deleted from the logic block until you press  
       Commit Data .

   2.  Press the  Commit Data  function key now.

Modifying a Step.   

You can now change an existing step.  When you entered step 8, you
entered the ENTER command as it should finally appear, but this did not
point to the correct step at the time.  The adjustments HP ALLBASE/4GL
made to this step number when you deleted step 9 mean that the ENTER
command now refers to the wrong step.

You now need to change this command so that, once again, it refers to the
correct step.

   1.  Position the cursor at the Step Number field and follow these
       steps. 

Action                    Explanation 

------------------------------------------------------------------------------

Enter 8.                  The cursor moves to the action field.

Press Return              Since the default action for an existing step is
                          Change, the current contents of the step are
                          displayed in an IF window and the cursor is
                          positioned in the first field of the window.

Press Tab seven times     This moves the cursor through the fields to the
                          THEN field on the screen.

Type 11 over the number   This alters the step so that if both test
10                        conditions in the IF command are true, processing
                          control skips to step 11.

Press  Commit Data        Commit the step and HP ALLBASE/4GL will display the
                          modified command.

   2.  Position the cursor on the Action field, regardless of step
       number, and display the whole process on the screen.

Action                    Notes 

Enter L                   The L action lists the current logic block to the
                          screen.  When you press Return, HP ALLBASE/4GL
                          clears the screen and lists the entire process.
                          Any lines that are too long to fit on the screen
                          will be wrapped around to the next line.

Press Return              This returns you to the process details screen.

   3.  Press the  Generate Process  function key to generate the modified
       product_proc process.

       If you have entered the process exactly as it's listed at the
       beginning of this section, you won't receive any generate error
       messages.  If you receive any generate errors, check that the
       storage items you defined previously are correctly named.  This is
       the most likely source of error.



MPE/iX 5.0 Documentation