Tips for Building Dual-interface Programs

The key to building dual-interface programs is being able to determine which kind of system you are using. ACUCOBOL-GT provides two methods to accomplish this:

  1. You can determine whether you are running under a character or graphical system by using the ACCEPT FROM TERMINAL-INFO verb. The HAS-GRAPHICAL-INTERFACE field is true when the host system is graphical, otherwise it is false. You can also use the WIN$VERSION library routine to get more detailed information about the Windows host operating system.
  2. In the Screen Section, you can automate the detection of character and graphical systems with the CHARACTER and GRAPHICAL reserved word labels to indicate entries that apply to only one system. See Graphical vs Textual Modes for more information.

You have a great deal of flexibility in how you implement dual interface programs. On one extreme, you can have completely separate interfaces for character and graphical systems. On the other, you can have a uniform interface with only minor differences between them. Here are some ideas to consider:

  1. If you are happy with your existing character interface, you may want to leave it alone and simply develop a new graphical interface. You could either start from scratch, or use your existing character interface as a starting point. If you decide to have completely separate interfaces, then you should start by isolating your character interface into one branch of an IF statement that tests HAS-GRAPHICAL-INTERFACE. You then develop the graphical interface in the other branch. Exactly the best way to do this depends on the structure of your code.
  2. If your existing character interface does not use the Screen Section, consider using the Screen Section for the graphical interface. While using the Screen Section is not required, it is easier because it automates all of the mouse handling and transfer of control between screen fields.
  3. If you do use the Screen Section for your character interface, you can use the CHARACTER and GRAPHICAL reserved word labels to do customization. You could do this either globally, by creating separate level 01 screen items for each system, or individually on selected fields. Note that you may have two screen items with the same name, as long as one is a CHARACTER item and the other is a GRAPHICAL item. This allows you to have a single set of interface code in the Procedure Division while still coding different screens.
  4. Consider employing some of the tips from the single-interface model. The more similar your two interfaces are, the easier they are to maintain.