Modernize your character application

Question ID : 327
Created on 2022-04-19 at 5:10 AM
Author : Veryant Support [support@veryant.com]

Online URL : http://support.veryant.com/support/phpkb/question.php?ID=327



This guide discusses the modernization process of a legacy COBOL application with character-based user interface.
It demonstrates the necessary steps to transform the character-based user interface into a graphical user interface.

The code snippets used by this guide are taken from the modernization examples installed with isCOBOL in the folder sample/modernization.

For an easy conversion of the user interface, it's good practice to have the user interface management programming separated from the backend processing.
The installed example is an application of this kind, with the user interface in a program called "CUSTOMER.cbl", and the data processing in a separate program called "PCUSTOMER.cbl"

The starting point is a character-based screen whose Screen Section definition is as follows:

   01 s1.
      03 "Customer code:"        line 3 col 2.
      03 using cust-code         col + 2 high prompt.
      03 "First name: "          line 4 col 2.
      03 using Cust-First-Name   col + 2 high prompt.
      ...

   01 s-func.
      03 "F1=Lookup"             line 23 col 2 reverse.
      03 "F3=Delete"             col + 2 reverse.
      ...

And displayed on a window described simply as "display window"

At runtime, the screen shows as follows:

The minimal modification that can be done to the Screen Section in order to convert to a graphical screen is to change text labels and FROM fields to LABEL controls and USING fields to ENTRY-FIELD controls as follows:

   01 s1.
      03 label "Customer code:"              line 3 col 2.
      03 entry-field using cust-code         col + 2 high prompt.
      03 label "First name: "                line 4 col 2.
      03 entry-field using Cust-First-Name   col + 2 high prompt.
      ...

It makes sense also to replace the text that describes an action with graphical PUSH-BUTTON controls as follows:

   01 s-func.
      03 push-button title "F1=Lookup"         line 23 col 2
                     size 9 self-act exception-value 1.
      03 push-button title "F3=Delete"         col + 2 
                     size 9 self-act exception-value 3.
      ...

And these screens need to be displayed on a graphical window, in our case described as:

   display standard graphical window
           background-low
           title "CUSTOMER MAINTENANCE"
           cell size is entry-field font
           size 84
           lines 18
           label-offset 10
           control font fixed-font
           handle h-main

After this modification, the screen appears as follows:

Note - if you wish to assign a special attribute to all the fields, for example if you want all the push-buttons to have the SELF-ACT style, you can use the compiler configuration property

iscobol.compiler.gui..defaults
instead of writing "SELF-ACT" in every push-button description in the Screen Section.

Even though the screen is graphical it's still not perfect; it doesn't look like a modern and appealing screen. A further effort is suggested in the installed sample in order to fully modernize a screen, such as:

Refer to CUSTOMER.cbl in sample/modernization/graphical/3-full-gui for the code using following steps.

After these changes, the screen will look like this:

It's a dramatic visual difference between the character and final modernization screens, with a minimal amount of effort.
We hope our modernization samples and this guide help you over the first hurdle of getting started.



Back to Original Question