Highlighted
Absent Member.
Absent Member.
1822 views

Screen Sectio Examle

Is  there an example of a COBOL program that uses the Screen Section available.

Thanks,

Tags (2)
0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Screen Sectio Examle

Hello,

You might want to look at the example in C:\Users\Public\Documents\Micro Focus\Visual COBOL\Samples\Interface Mapping Toolkit\ServiceInterfaces\BookDemo

There is no solution or project for this example, but you may create a new one where booktest.cbl is the main program and book.cbl the subprogram.

Regards,

–Ғɑɳօ
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Screen Sectio Examle

There is also the following ADSAMP example which is from Net Express which will also work under Visual COBOL. This also demonstrates how to set some of the keyboard configuration options through calls to run-time routines.

      ******************************************************************
      * Copyright Micro Focus International Ltd 1996-1998.
      * All Rights Reserved.
      ******************************************************************

      ****************************************************************
      * This program assumes that the default configuration has been *
      * selected using Adiscf.                                       *
      ****************************************************************

       special-names.
           cursor is cursor-position
           crt status is key-status.

       data division.
       working-storage section. 

      **************************************************
      * Parameters to be used for the x"AF" calls.
      **************************************************
       
       01 set-bit-pairs                 pic 9(2) comp-x value 1.
       01 get-single-character          pic 9(2) comp-x value 26.
       
       01 enable-esc-and-f1.
           03 filler                    pic 9(2) comp-x value 1.
           03 filler                    pic x value "1".
           03 filler                    pic 9(2) comp-x value 0.
           03 filler                    pic 9(2) comp-x value 2.
       
       01 disable-all-other-user-keys.
           03 filler                    pic 9(2) comp-x value 0.
           03 filler                    pic x value "1".
           03 filler                    pic 9(2) comp-x value 2.
           03 filler                    pic 9(2) comp-x value 126.
       
       
       01 enable-slash-key.
           03 filler                    pic 9(2) comp-x value 1. 
           03 filler                    pic x value "3".
           03 filler                    pic x value "/".
           03 filler                    pic 9(2) comp-x value 1. 

      **************************************************
      * Status returned after termination of an ACCEPT.
      **************************************************
       01 key-status.
           03 key-type                  pic x.
           03 key-code-1                pic 9(2) comp-x.
           03 key-code-1-x              redefines key-code-1 pic x.
           03 key-code-2                pic 9(2) comp-x.
       
      **************************************************
      * Cursor-Position is returned by ADIS containing 
      * the position of the cursor when the ACCEPT was 
      * terminated.
      ***************************************************
       01 cursor-position.
           03 cursor-row                pic 99.
           03 cursor-column             pic 99.
       
      **************************************************
      * Work areas used by the program.
      ************************************************** 
       01 work-areas.
           03 wa-name                   pic x(30).
           03 wa-address-line-1         pic x(40).
           03 wa-address-line-2         pic x(40).
           03 wa-address-line-3         pic x(40).
           03 wa-address-line-4         pic x(40).
           03 wa-age                    pic 999 value 0.
       
       01 exit-flag                     pic 9(2) comp-x value 0.
       
       
      **************************************************
      * Screen Section.
      **************************************************
       screen section.
       
       01 main-screen.
           03 blank screen.
           03 line 2 column 27 
               value "Typical Data Entry Screen".
           03 line 3 column 27 
               value "-------------------------".
           03 line 5 column 1 value "name     [".
           03 pic x(30) using wa-name highlight prompt " ".
           03 value "]".
           03 line 7 column 1 value "address  [".
           03 pic x(40) using wa-address-line-1 highlight prompt " ".
           03 value "]".
           03 line 8 column 1 value "         [".
           03 pic x(40) using wa-address-line-2 highlight prompt " ".
           03 value "]".
           03 line 9 column 1 value "         [".
           03 pic x(40) using wa-address-line-3 highlight prompt " ".
           03 value "]".
           03 line 10 column 1 value "         [".
           03 pic x(40) using wa-address-line-4 highlight prompt " ".
           03 value "]".
           03 line 12 column 1 value "age      [".
           03 pic zz9 using wa-age highlight prompt " ".
           03 value "]".
           03 line 20 column 1 value
              "---------------------------------------------------------
      -       "-----------------------".
           03 line 21 column 1 value "f1" highlight.
           03 value "=".
           03 value "/h" highlight.
           03 value "elp".
           03 column 75 value "esc" highlight.
           03 value "ape".
       
       01 help-screen.
           03 blank screen.
           03 line 1 column 34 value "Help Screen".
           03 line + 1 column 34 value "-----------".
           03 line 4 value "escape" highlight.
           03 value "     Quit this program.".
           03 line 6 column 1 value "f1 or /h" highlight.
           03 value "   View this help screen.".
           03 line 8 column 1 
               value "Use the cursor keys to move around ".
           03 value "the fields on the screen.". 
           03 value " Pressing enter".
           03 line + 1 column 1 value "accepts the data ".
           03 value "and presents a new blank form to fill in.".
           03 line 24 column 25 
               value "Press any key to continue ...".
       
      **************************************************
      * Procedure Division.
      **************************************************
       
       procedure division.
       entry-point section.
       
      * First we want to ensure that the keys are enabled as we want
      * them. Enable the Escape and F1 keys.
       
           call x"AF" using set-bit-pairs 
                            enable-esc-and-f1
       
      * disable every other user function key. 
           call x"AF" using set-bit-pairs
                            disable-all-other-user-keys
       
      * set up "/" key to act as a function key and terminate 
      * the ACCEPT operation.
       
           call x"AF" using set-bit-pairs 
                            enable-slash-key
       
      * Now ensure that the cursor position will be returned when an
      * ACCEPT is terminated. Setting to row 1, column 1 will ensure
      * that the cursor will be initially positioned at the start of 
      * the first field.
       
           move 1 to cursor-row
           move 1 to cursor-column
       
      * Loop until the Escape key is pressed.
       
           perform until exit-flag = 1
               display main-screen
               accept main-screen
               evaluate key-type
                 when "0"
       
      * The ACCEPT operation terminated normally; that is the Enter key
      * was pressed. In this case, we simply blank out the work areas
      * and restart in the first field.
       
                   initialize work-areas
                   move 1 to cursor-row
                   move 1 to cursor-column
       
                 when "1"
       
      * A user function key has been pressed. This will either be
      * Escape or F1 as all others have been disabled.
       
                   if key-code-1 = 0
      
      * Escape has been pressed, so we wish to leave the program.
       
                       move 1 to exit-flag
                   else
      
      * F1 has been pressed so display the help screen. 
                       perform display-help-screen
                  end-if
       
                 when "3"
       
      * A data key has terminated the ACCEPT operation. It must be "/"
      * as no other keys have been enabled to do this. Now get the 
      * next character to see if "H" or "h" has been pressed.
       
                   call x"AF" using get-single-character
                                    key-status
                   if key-type = "3" and
                     (key-code-1-x = "h" or 
                      key-code-1-x = "H")
                       perform display-help-screen
                   end-if
       
               end-evaluate
           end-perform
           stop run.
       
       display-help-screen section.
      
      * Display the help screen and then wait for a key to be pressed.
       
           display help-screen
           call x"AF" using get-single-character
                            key-status.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.