Skip to Content

Can I modify the GUI controls of a Screen program from a called routine?

Estimated Reading Time: 1 Minutes

Sometimes you may want to have some special routines that could be capable to apply similar changes to the GUI controls of one or more screen programs.

For example, let's say you have a combo-box that shows the names of the days of a week and you use such combo box on many screen programs and you want to avoid having each program fill that combo-box. Instead, you want a routine that may fill the combo-box for all the screen programs that require it.

This can be easily done by passing the handle of the control, defined in the calling program, to the called routine. And then, the called routine may populate it in a generic way.

The critical code for that could be as follows:

   WORKING-STORAGE SECTION.
   ...
   77  cb1-handle handle of combo-box.
   ...
   SCREEN SECTION.
   01  screen-1.
       03 CB1
          Combo-box
   ...
Then in Procedure Division:
   ...
   set cb1-handle to handle of cb1.
   call "filldays" using cb1-handle.
   ...
In the calling program:

   LINKAGE SECTION.
   77  cb1-handle handle of combo-box.

   PROCEDURE DIVISION USING cb1-handle.

   MAIN.
       modify cb1-handle 
              item-to-add "Monday"
              item-to-add "Tuesday"
              item-to-add "Wednesday"
              item-to-add "Thursday"
              item-to-add "Friday"
              item-to-add "Saturday"
              item-to-add "Sunday".
   ...

Attached you can find two sample programs that fully illustrate this sample case.

Can I modify the GUI controls of a Screen program from a called routine?
  • Attached Files
  • filldays.cbl (661 Bytes) 10
  • main.cbl (1.59 KB) 7