Field Lenght

Is there any function is avialable in VISUAL COBOL to calculate the Field-Length. We are actually facing one problem like where cursor is blinked on SCREEN-SECTION we are not able to capture the total length of the Cursor. I have tried with X"A7" feature but no luck. Any idea will be highly appriciated.

  • Partha,

    Can you explain in more detail what it is that you want to achieve ?

    A cursor can only ever be one character wide on a character mode display (which I am assuming given the other question you asked) and the only function that the X"A7" call provides is to set the height of the cursor, for example whether it is an underline or a block. Is that what you are trying to change ? if so, what are you trying to change it to ? And are you aware that if you toggle the Insert key it will be changed by the run-time system anyway so any value you set with x"A7" will probably be lost at that point ?

    Gael

  • Hi Gael,

    I have attached one screen print for your reference. Our objective is to show the help screen for each field displayed on the screen. Now to achive this we have enabled F12 key interuption inside the program. To capture the Cursor location we have also used the CBL_GET_CSR_POS module. But through this module we only know the position of Cursor currently it blinked. But as per our requirement e.g from screenshot I have attached, to activate the help screen for Policy Holder Addrees is difficult as Cursor may scroll upto 10 characters and at position of cursor on the screen User can hit the F12 key where only 1st occurance of Cursor may show us the help screen as we capture the location and hard coded in the program. 

    So I seek your advice on is there any functionality is avaiable to capture the filed location rather each time we are calculating the cursor position and hard coded in the program.

    2nd Requirement is that after display the Help screen Cursor should be located at the same postion where in our case if we use accept the screen again cursor will locate the very first field.

     

      

  • Verified Answer

    Partha,

    I think that both points are covered by use of CURSOR IS, as I described in a separate response. There is no means I am aware of of determining the location of an ACCEPT field but if you are using F12 to terminate the ACCEPT and have a CRT STATUS item in SPECIAL-NAMES the item will indicate the key that terminated the ACCEPT and the CURSOR IS item will tell you the cursor position and you should be able to determine the field you were on from that. The CURSOR IS will also control the location of the cursor when you redo the ACCEPT so provided it is a valid position for the screen definition the cursor should be placed back on that field. Below is a a very old sample showing the use of F1 to display a help screen 

         ****************************************************************

         * 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.

     

    :

     

    Gael

  • It is a great help!!!

    Seek one more suggestion whether we can pass any value to cursor position itself.  

  • It is a great help!!!

    Seek one more suggestion whether we can pass any value to cursor position itself.  

  • Partha,

    In the sample above there is code that does :

                      move 1 to cursor-row

                      move 1 to cursor-column

    to set the cursor position for the next ACCEPT. As those values do not correspond to a position of a value that can be modified within the screen the cursor will be positioned on the first field e the name field. If you wanted to set it on a specific field, for example the address field, you would move 7 to cursor-row and 10 to cursor-column.

    Gael