How to modify the GUI controls of a Screen program from a called routine.
Estimated Reading Time: 1 MinutesSometimes you may want to have some special routines to apply similar changes to GUI controls of one or more screen programs. You can do this by passing the handle of the control, defined in the calling program, to a called program which would then modify the control.
For example, let's say you have a combo-box that shows the names of the days of the week on multiple screen programs. You want a routine to fill the combo-box with the days of the week for any screen program that requires it rather than having the same code in each program. The 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.