Skip to main content

Problem:

Is it possible to terminate an ACCEPT using the TAB and F8 keys?  If so, how are these keys detected within a COBOL program?

Resolution:

Yes it is possible to terminate an ACCEPT with the TAB and F8 keys.  This is done by calling ADIS and enabling a function key (F8) and an ADIS key (TAB).  The following program demonstrates how this is done and also how to detect the use of these keys.

There are many other options and these can be found in the online documentation for ADIS.

       special-names.

           crt status is key-status.

       working-storage section.

       01  key-status.

           03  key-type                pic x.

           03  key-code-1              pic 9(2) comp-x.

           03  key-code-2              pic 9(2) comp-x.

       01  set-bit-pairs               pic 9(2) comp-x value 1.

       01  user-key-control.

           03  user-key-setting        pic 9(2) comp-x.

           03  filler                  pic x value "1".

           03  first-user-key          pic 9(2) comp-x.

           03  number-of-keys          pic 9(2) comp-x.

       01  adis-key-control.

           03  adis-key-setting        pic 9(2) comp-x.

           03  filler                  pic x value "2".

           03  first-adis-key          pic 9(2) comp-x.

           03  number-of-adis-keys     pic 9(2) comp-x.

       01  data-item                   pic x(10).

       procedure division.

           display

              spaces at 0101

              "ADIS TEST PROGRAM" at 0101

              "-----------------" at 0201

              "Enter data (Exit to end) :" at 0401

           end-display.

           move spaces to data-item.

           perform proc-accept until data-item = "Exit"

           stop run.

       proc-accept section.

      * -- Enable TAB.

           move 1 to adis-key-setting.

           move 8 to first-adis-key.

           move 1 to number-of-adis-keys.

           call x"AF"

              using set-bit-pairs

                    adis-key-control

           end-call.

      * -- Enable F8.

           move 1 to user-key-setting.

           move 8 to first-user-key.

           call x"AF"

              using set-bit-pairs

                    user-key-control

           end-call.

           accept data-item at 0428.

           display spaces at 0601.

           evaluate key-type

           when "0"

              if key-code-1 = 48

                 display "ACCEPT terminated by ENTER key" at 0601

              else

                 display "ACCEPT terminated by auto-skip" at 0601

              end-if

           when "1"

              evaluate key-code-1

              when 8

                 display "ACCEPT terminated by F8" at 0601

              end-evaluate

           when "2"

              evaluate key-code-1

              when 8

                 display "ACCEPT terminated by TAB" at 0601

              end-evaluate

           end-evaluate.

       proc-accept-exit.

           exit.

Old KB# 1493