Menu

How to set (not get) the cursor screen position during ACCEPT

2023-04-29
2023-05-11
  • W. Burke Cabaniss

    I am converting my text editor program from RM COBOL. RM has an ACCEPT command CURSOR option to position the cursor in the accepted data field. My text editor accepts whole lines, or 80 byte segments of longer lines. As an example situation on line 2 of text I may press the down arrow key to go line 3 below. When I pressed the down arrow my cursor was on column 35. Although I must ACCEPT LINE 3 COL 1 WITH SIZE 80 i need the cursor to be positioned line 3 column 35.

    i do use CBL_GET_CURSOR_POS. i do use SPECIAL-NAMES. CURSOR IS... These give me the exact cursor position. They solve the previous problems I have discussed (-fline-col... doesn't work for ACCEPT). To complete my programs I need is a way to position the cursor on the 80 character line I am accepting.

    I will appreciate any help.

     
    • Simon Sobisch

      Simon Sobisch - 2023-04-30

      SPECIAL NAMES should also work for positioning... at least if you can use SCREEN SECTION.

      What is the exact syntax of RM you refer to?

       
  • W. Burke Cabaniss

    I have everything solved in converting three large (1000 line plus) RM COBOL programs, except this. Logic requires "ACCEPT LINE {#} POS 1 WITH SIZE 80" (a whole text line) but with the cursor positioned elsewhere, such as POS 35. i need to specify the position to be used DURING the ACCEPT. RM COBOL did this by a CURSOR parameter which is an offset from the ACCEPT POS/COL. A manual spec is attached.

    i will greatly appreciate any help.

     
  • W. Burke Cabaniss

    This is separate, but related comments on ACCEPT and DISPLAY. Perhaps this is a good place to mention them for possible consideration in future GNU COBOL versions. I have handled them in my conversions with extra work:

    ACCEPT {x} LINE 0 COL 0 does not accept from the screen position of the previous ACCEPT or DISPLAY. DISPLAY does so, also if LINE and COL are unspecified. I have set cobc compile configuration file rm-strict.conf parameter "line-col-zero-default: yes". It is stated to position an ACCEPT/DISPLAY following the previous ACCEPT/DISPLAY when LINE and COL are unspecified, as if LINE 0 COL 0. It does not work for ACCEPT.

    DISPLAY ... WITH ... color and highlight and such attributes only applies to the first data item. One might want a command such as "DISPLAY 'ERROR' LINE 4 COL 1 WITH HIGHLIGHT FOREGROUND-COLOR 6 ERROR-MESSAGE ', PRESS ENTER '." and to have the attributes pertain to the whole DISPLAY statement. Now this can only be done by four verbose DISPLAY statements. It would also be helpful to have brief alternatives for the verbose words such as FOREGROUND-COLOR.

    My programs now have hundreds of DISPLAY statements and many ACCEPT's, but only about four color and highlight attribute combinations such as "HIGHLIGHT FOREGROUND-COLOR 3". RM COBOL provided that the attribute combinations could be stored as a data item, referenced by parameter CONTROL as in "CONTROL BLUE" for the example in this paragraph.

    These are ideas. My work is done. I am extremely impressed with GNU COBOL features and adaptability. I only have the remaining problem first explained in this topic.

     
  • Simon Sobisch

    Simon Sobisch - 2023-05-07

    Can you please post an example program that uses this function doing an ACCEPT of two fields using this which does work with RM/COBOL as expected?
    While I do get the idea I'd like to have a "working" test program for that - actually the coding changes within GnuCOBOL to handle that should be not that much.

     
  • Simon Sobisch

    Simon Sobisch - 2023-05-08

    ... you could have specified that this already compiles fine with GnuCOBOL 3.1.2, just raises a warning that ACCEPT ... WITH CURSOR is pending and doesn't work...

    Still I'd like to see some minimal example programs we could test with when implementing this.

     
  • W. Burke Cabaniss

    Oh, It isn't documented in the GNU COBOL manual and I never tried ACCEPT... WITH CURSOR. i didn't know it was a pending consideration. That's the whole answer, and I can't imagine alternative logic for my program. Lack of the feature prevents conversion of my third big utility program but that's OK. Maybe in future you will implement it.

    I also will have difficulty in designing a minimal-sized text editor program for your testing. My text editor program with many special COBOL features has 4135 lines. I'll see what I can do.

    Thank you for your help. All the rest of my conversions have been wonderful. I only had the few suggestions of last week for future versions.

     
    • Simon Sobisch

      Simon Sobisch - 2023-05-09

      Maybe in future you will implement it.

      Actually I have that done locally, plan to commit it in the next hours :-)
      That also contains the following test program, you may want to have a look if I got that right:

             IDENTIFICATION   DIVISION.
             PROGRAM-ID.      prog.
             DATA             DIVISION.
             WORKING-STORAGE  SECTION.
             77  cur-pos      pic 9(04).
             01  success-flag PIC X VALUE 'Y'.
                 88  success  VALUE 'Y', 'y'.
             01  ws-x-20      PIC X(20).
             PROCEDURE DIVISION.
             testme.
                 set environment 'COB_SCREEN_EXCEPTIONS' to 'TRUE'
                 set environment 'COB_SCREEN_ESC'        to 'TRUE'
      
                 DISPLAY "If the cursor below is positioned at the 'C'"
                     LINE 1 COLUMN 1.
                 DISPLAY "(third column in field) below, then position it at"
                     LINE 2 COLUMN 1.
                 DISPLAY "the 'E' (fifth column) and press ENTER."
                     LINE 3 COLUMN 1.
      
                 MOVE "ABCDEFG   " TO WS-X-20.
                 MOVE 0003         TO cur-pos.
                 ACCEPT WS-X-20
                     LINE 5 COLUMN 3
                     WITH
                         AUTO-SKIP
                         SIZE 10
                         CURSOR cur-pos
                         UPDATE.
      
                 IF cur-pos = 0005 AND COB-CRT-STATUS = 0
                     GOBACK RETURNING 0
                 ELSE
                     GOBACK RETURNING 1
                 END-IF
                 .
      
       
      • Mickey White

        Mickey White - 2023-05-10

        downloaded the nightly snap and this program still has cursor at A not C. FYI ? linux.

         
        • Simon Sobisch

          Simon Sobisch - 2023-05-10

          That's only a local build. Tests are finished including the testsuite, so I think I'll commit support for CURSOR and COLOR and preparation for CONTROL in 4-6 hours.

           
          👍
          1
  • W. Burke Cabaniss

    Good. I have written the minimal test program you requested. It was as small as I could do. It displays an explanatory screen to mimic full screen edit of a file. Up and down arrow keys test whether COL is always 1 or not on the line above/below.

     

    Last edit: W. Burke Cabaniss 2023-05-11
  • W. Burke Cabaniss

    I have just copied and compiled (CURSOR warning only) and run your test program. It initiated on the 'A'. i positioned the cursor on the 'C' and got RC=1. It is the expected result if CURSOR isn't implemented. I assume my version (downloaded about year-end) or an option is at fault.

    Your test program is much smaller.

     
  • W. Burke Cabaniss

    Just one more last thought on ACCEPT. i know the CONVERT parameter is recognized but not implemented in GNU COBOL. It relates to conversion of keyed data (alphanumeric entry) into numeric formats. In my work I came across a test program I used in 2007 in conversion to RM COBOL. It tests MOVE of various alphanumeric fields to various numeric fields, which seems to me a similar action. I compiled it with cobc and ran it. Only one result in about 15 differed from RM and from what I think is a correct conversion. It may have been my error in coding. I have attached the test program in case you are interested.

    Again, thank you and I don't intend to bother you further on this.

     
    • Simon Sobisch

      Simon Sobisch - 2023-05-10

      @burkec that seems interesting but unrelated to this topic - please create a new topic for that also explaining what we may see with this test code.

       
      • W. Burke Cabaniss

        You're right. It relates to ACCEPT...WITH CONVERT. I was impressed to find that GNU MOVE did just what I would expect CONVERT to do, only one exception which might be my error. I assume GNU cobc program logic association and thought this would be helpful in development.

        In the topic re:ACCEPT...WITH CURSOR i have included four or five ideas/suggestions related to ACCEPT and parameters for it. I didn't have any issues or ideas anywhere else. The rest of my conversions were clear and direct and easy.

        Should I copy my suggestions in this topic to a new topic in this forum such as "Suggestions re:parameters and operation of the ACCEPT statement" ? Or is there a better forum for future version suggestions?

         
        • Simon Sobisch

          Simon Sobisch - 2023-05-11

          When you have a concise "I suggest this/that" with useful limited scope , then it is normally best to create an issue in the wish list tracker: https://sourceforge.net/p/gnucobol/feature-requests/ (after a quick search in there to not create duplicates) - in this case you may want to add useful information to [feature-requests:#433], so far it has no sample programs for the main request or additional "comment code".

           

          Related

          Wish List: #433

  • Simon Sobisch

    Simon Sobisch - 2023-05-10

    Just a note: CURSOR phrase on ACCEPT is now implemented with [r5042] , along with the two other options to adjust the attributes for extended screenio at runtime using COLOR and CONTROL phrase (the later needs a reasonable parsing for all those texts and variants, something that @chaat agreed to have a look at).

    Back to the original topic... while the CURSOR phrase now works (I think "as it should", but I'd like others to test that more) it is highly suggested to not be used for new programs - as it is a rare extension and the standard option with CURSOR clause in SPECIAL-NAMES is much more portable (it has one main difference - it allows you to position into "empty" data, while the extension will position at the last data [it wasn't clear from the docs if "last position with data" is correct or if it would be "position after last position"]), if wanted this could be also done with standard COBOL by calculating the CURSORposition accordingly.


    Deep-links for the nighty builds:

     

    Related

    Commit: [r5042]


    Last edit: Simon Sobisch 2023-05-10

Anonymous
Anonymous

Add attachments
Cancel