1

I am a beginner in COBOL and I am having a little error. When I do a simple statement like ACCEPT (variable) FROM ESCAPE KEY, the program doesn't react to the esc key. I understand that something needs to be done with the compiler but I'm not too sure. I use OpenCobolIDE. Does anyone know what's wrong?

I've searched everywhere but can't find an answer. I leave my Cobol code here although it is very simple.It is basically a menu in Spanish (my native language) in which if you press esc the program will end.

   ID DIVISION.
   PROGRAM-ID. ALUMAIN.
  * Menu principal de la aplicación. ALUMAIN.CBL
   ENVIRONMENT DIVISION.
   DATA DIVISION.
   WORKING-STORAGE SECTION.
   77 OK PIC X.
   77 ESC PIC 99.
   88 SALIDA VALUE 27.
   PROCEDURE DIVISION.
   XXX.
       PERFORM UNTIL SALIDA OR OK = "S" OR OK = "s"
         DISPLAY "SISTEMA DE ALUMNOS" LINE 1 POSITION 31
             ERASE SCREEN
                 "A ALTAS"          LINE 8 POSITION 33
                 "B BAJAS"          LINE 10 POSITION 33
                 "M MODIFICACIONES" LINE 12 POSITION 33
                 "C CONSULTAS"      LINE 14 POSITION 33
                 "L LISTADO"        LINE 16 POSITION 33
                 "S SALIR (ESC)"    LINE 18 POSITION 33
         MOVE 0 TO ESC
         ACCEPT OK LINE 25 POSITION 79
         ACCEPT ESC FROM ESCAPE KEY
         IF OK = "A" OR OK = "a"
                CALL "ALUALTAS"
         END-IF

         IF OK = "B" OR OK = "b"
                CALL "ALUBAJA"
         END-IF

         IF OK = "C" OR OK = "c"
                CALL "ALUMNOS"
         END-IF

         IF OK = "M" OR OK = "m"
                CALL "ALUMODI"
         END-IF

         IF OK = "L" OR OK = "l"
                CALL "ALUMLIST"
         END-IF

       END-PERFORM
       STOP RUN.

1 Answers1

0

You very likely would have to go to the runtime settings, enable "run in external terminal" as well as adding the settings COB_SCREEN_EXCEPTIONS=Y and COB_SCREEN_ESC=Y there or do so in the code.

As OCIDE is not maintained any more you likely want to setup a custom compiler to update from the obsolete GnuCOBOL 1.1 or switch to Gix-IDE in general.

Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38
  • I've tried and it doesn't work. I suppose that there is something in the environment as you have commented that does not work correctly – HombresDios Nov 06 '22 at 22:22
  • So you did use the external terminal and set the two environment variables in the COBOL code as noted in the link - and it still did not work? – Simon Sobisch Nov 06 '22 at 22:24
  • Yes, it works. The code just doesn't do what I expected. Thank you – HombresDios Nov 07 '22 at 11:57
  • @HombresDios if this answer is useful for you, please upvote it (also applies to _any_ answer you see to _any_ question); if it solved your original question please make it as accepted answer (which may not even the best, but the one that solved the _initial_ issue for the person asking the question). If the answer just "led you to the right direction", you may upvote it, create an answer yourself with the important parts you found and mark your answer as accepted. – Simon Sobisch Nov 09 '22 at 09:09