Menu

function keys and escape key not returning values in cob-crt-status

Anonymous
2016-11-30
2018-12-03
  • Anonymous

    Anonymous - 2016-11-30

    function keys and escape key not returning values in cob-crt-status

     
  • Simon Sobisch

    Simon Sobisch - 2016-11-30

    Aha. What does cobc --info says?
    Not sure if this is the case (the information is missing) but values are only stored in cobc-crt-status if an "extend" ACCEPT is used. What did you do?

     
  • Anonymous

    Anonymous - 2016-12-02

    Hi Simon,

    cobc -i output...

    cobc (GNU Cobol) 2.0.0
    Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
    Copyright (C) 2006-2012 Roger While
    Copyright (C) 2009,2010,2012,2014,2015 Simon Sobisch
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Built     Jun 15 2016 11:56:04
    Packaged  Oct 25 2015 21:40:28 UTC
    C version "4.4.6 20120305 (Red Hat 4.4.6-4)"
    
    Build information
    Build environment        : x86_64-pc-linux-gnu
    CC                       : gcc -std=gnu99
    CPPFLAGS                 :
    CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char
                               -Wall -Wwrite-strings -Wmissing-prototypes
                               -Wno-format-y2k -U_FORTIFY_SOURCE
    LD                       : /usr/bin/ld -m elf_x86_64
    LDFLAGS                  : -Wl,-z,relro,-z,now,-O1
    
    GNU Cobol information
    COB_CC                   : gcc -std=gnu99
    COB_CFLAGS               : -I/usr/local/include -pipe
    COB_LDFLAGS              :
    COB_LIBS                 : -L/usr/local/lib -lcob -lm -lgmp -lncursesw
                               -ldb
    COB_CONFIG_DIR           : /usr/local/share/gnu-cobol/config
    COB_COPY_DIR             : /usr/local/share/gnu-cobol/copy
      env: COB_COPY_DIR      : ://home/rcs/fmt
    COB_MSG_FORMAT           : GCC
    COB_MODULE_EXT           : so
    COB_EXEEXT               :
    64bit-mode               : yes
    BINARY-C-LONG            : 8 bytes
    Extended screen I/O      : ncursesw
    Variable format          : 0
    Sequential handler       : Internal
    ISAM handler             : BDB
    [rcs@mdccobol prg]$
    

    Source code "samplercs.cbl"

    ::cobolfree
           IDENTIFICATIOn division.
           PROGRAM-ID. sample.
           ENVIRONMENT DIVISION.
           configuration section.
           source-computer. intel.
           object-computer. intel.
           special-names.
            console is crt
            crt status is COB-CRT-status.
           DATA DIVISION.
           working-storage section.
            copy "screenio.cpy".
              01 ws-eof pic x(1) value "N".
              01 ws-status pic 9(4) value zeroes.
              01 ws-ecode pic x(6) value spaces.
              01 key-status.
                 05 key-code-1 pic 99.
                 05 key-code-2 pic 99.
           screen section.
              01 ws-scr1.
                    05 line 2 column 2  pic x(80) value "     ABC".
                    05 line 10 column 2   pic 9(4) using key-status.
    
            procedure division.
            set environment "COB_SCREEN_ESC" TO "Y".
            SET ENVIRONMENT "COB_SCREEN_EXCEPTIONS" TO "Y".
          * display ws-scr1.
          * accept ws-scr1.
            accept ws-ecode.
            accept key-status from escape key.
            If cob-crt-status = cob-scr-f1
            display " F1 key pressed".
            display "key" key-status .
            accept ws-ecode.
            stop run.
    

    cobcrun -i output ....

    [rcs@mdccobol prg]$ cobcrun -i
    libcob (GNU Cobol) 2.0.0
    Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
    Copyright (C) 2006-2012 Roger While
    Copyright (C) 2009,2010,2012,2014,2015 Simon Sobisch
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Built     Jun 15 2016 11:55:59
    Packaged  Oct 25 2015 21:40:28 UTC
    
    Build information
    Build environment        : x86_64-pc-linux-gnu
    CC                       : gcc -std=gnu99
    CPPFLAGS                 :  (default)
    CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char -Wall
                               -Wwrite-strings -Wmissing-prototypes
                               -Wno-format-y2k -U_FORTIFY_SOURCE
    LD                       : /usr/bin/ld -m elf_x86_64
    LDFLAGS                  : -Wl,-z,relro,-z,now,-O1
    
    C version "4.4.6 20120305 (Red Hat 4.4.6-4)"
    GNU Cobol information
    COB_MODULE_EXT           : so
    Dynamic loading          : System
    "CBL_" param check       : Disabled
    64bit-mode               : yes
    BINARY-C-LONG            : 8 bytes
    Extended screen I/O      : ncursesw
    Variable format          :  (default)
    Sequential handler       : Internal
    ISAM handler             : BDB
    [rcs@mdccobol prg]$
    

    cobcrun -r output....

    [rcs@mdccobol prg]$ cobcrun -r
    GNU Cobol 2.0.0 runtime environment
     via  /usr/local/share/gnu-cobol/config/runtime.cfg
    
     Call environment
        : COB_LOAD_CASE         : not set
        : COB_PHYSICAL_CANCEL   : false (default)
        : COB_PRE_LOAD          : not set
        : COB_LIBRARY_PATH      : .:/usr/local/lib/gnu-cobol (default)
    
     File I/O
        : COB_VARSEQ_FORMAT     : 0 (default)
        : COB_FILE_PATH         : not set
        : COB_LS_FIXED          : false (default)
        : COB_LS_NULLS          : false (default)
        : COB_SORT_CHUNK        : 256 KB (default)
        : COB_SORT_MEMORY       : 128 MB (default)
        : COB_SYNC              : false (default)
        : DB_HOME               : not set
    
     Screen I/O
        : COB_BELL              : BEEP (default)
        : COB_REDIRECT_DISPLAY  : false (default)
     env: COB_SCREEN_ESC        : true
     env: COB_SCREEN_EXCEPTIONS : true
        : COB_INSERT_MODE       : false (default)
        : COB_TIMEOUT_SCALE     : 0 (1000) (default)
        : COB_LEGACY            : false (default)
    
     Miscellaneous
        : COB_DISABLE_WARNINGS  : false (default)
        : COB_ENV_MANGLE        : false (default)
        : COB_SET_TRACE         : false (default)
        : COB_TRACE_FILE        : not set
    
     System environment
     env: USERNAME              : 'rcs' (set by LOGNAME)
     env: LANG                  : 'en_US.UTF-8'
        : OSTYPE                : not set
     env: TERM                  : 'xterm'
        : LC_CTYPE              : C
        : LC_NUMERIC            : C
        : LC_COLLATE            : en_US.UTF-8
        : LC_MESSAGES           : en_US.UTF-8
        : LC_MONETARY           : en_US.UTF-8
        : LC_TIME               : en_US.UTF-8
    [rcs@mdccobol prg]$
    

    have run program as ....

    ./samplercs

    [rcs@mdccobol prg]$ cobc -i -m samplercs.cbl
    cobc (GNU Cobol) 2.0.0
    Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
    Copyright (C) 2006-2012 Roger While
    Copyright (C) 2009,2010,2012,2014,2015 Simon Sobisch
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Built     Jun 15 2016 11:56:04
    Packaged  Oct 25 2015 21:40:28 UTC
    C version "4.4.6 20120305 (Red Hat 4.4.6-4)"
    
    Build information
    Build environment        : x86_64-pc-linux-gnu
    CC                       : gcc -std=gnu99
    CPPFLAGS                 :
    CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char
                               -Wall -Wwrite-strings -Wmissing-prototypes
                               -Wno-format-y2k -U_FORTIFY_SOURCE
    LD                       : /usr/bin/ld -m elf_x86_64
    LDFLAGS                  : -Wl,-z,relro,-z,now,-O1
    
    GNU Cobol information
    COB_CC                   : gcc -std=gnu99
    COB_CFLAGS               : -I/usr/local/include -pipe
    COB_LDFLAGS              :
    COB_LIBS                 : -L/usr/local/lib -lcob -lm -lgmp -lncursesw
                               -ldb
    COB_CONFIG_DIR           : /usr/local/share/gnu-cobol/config
    COB_COPY_DIR             : /usr/local/share/gnu-cobol/copy
      env: COB_COPY_DIR      : ://home/rcs/fmt
    COB_MSG_FORMAT           : GCC
    COB_MODULE_EXT           : so
    COB_EXEEXT               :
    64bit-mode               : yes
    BINARY-C-LONG            : 8 bytes
    Extended screen I/O      : ncursesw
    Variable format          : 0
    Sequential handler       : Internal
    ISAM handler             : BDB
    [rcs@mdccobol prg]$ cobcrun samplercs
    libcob: Cannot find module 'samplercs'
    [rcs@mdccobol prg]$
    

    Have to map mf cobol accept key values to open cobol key values in online programs.

    Request suggestions
    Thanks

     

    Last edit: Simon Sobisch 2016-12-02
  • Simon Sobisch

    Simon Sobisch - 2016-12-02

    Some points here:

    1. the version you use is outdated, I highly suggest to either use rc2 or wait for rc3
    2. cobc -i will always output the compiler information. If you want the version input while compiling use -vv instead. If you intended to run the program after compilation use -j.
    3. With the current implementation (this may change with the next version, but not with GC 2.0) the output names (if none is given the sources file name is used) and PROGRAM-ID must match, otherwise you won't find them at run-time (-x goes around this, setting COB_PRE_LOAD can do, too). Therefore either rename the source, or the PROGRAM-ID or use cobc samplercs.cob -o sample.so && cobcrun sample or use cobc samplercs.cob && COB_PRE_LOAD=samplercs cobcrun sample.
    4. If you explicit define a CRT STATUS the variable must be defined. You can use the pre-defined COB-CRT-STATUS when you don't explicit define it (the simple fix is to replace line 9 of the sample with a period). You may intended to use crt status is key-status?

    BTW: Actual running the changed program (with current svn checkout) shows weird results here, I'll have to recheck this at home.

     
  • Anonymous

    Anonymous - 2016-12-02

    Thanks Simon.
    where do i get rc2 version for rhel. and how do I upgrade the existing setup without disturbing the current setup on rhel?

     
    • Simon Sobisch

      Simon Sobisch - 2016-12-02

      You can get rc-2 from https://sourceforge.net/projects/open-cobol/files/gnu-cobol/2.0/gnu-cobol-2.0_rc-2.tar.gz/download

      If you just want to test it:

      ::bash
      tar -xvf gnu-cobol-2.0_rc-2.tar.gz
      cd gnu-cobol-2.0
      ./configure # if some files are not found add --prefix=/usr/local
      make
      make checkall # test if the build works on your machine
      

      Then you can test this "in-tree" with

      ::bash
      bash      # start a new session to not overwrite your old environment
      . tests/atconfig && . tests/atlocal # temporary set the environment
      cobc -V   # do whatever you want with the test build
      exit      # return to the old environment
      

      If you want to install both and clean side-by-side you can change the --prefix during configure to point somewhere else - but when you want to call this version you need to use the full path, for example ./configure --prefix=/opt/gc2-tst and /opt/gc2-tst/bin/cobc -V.

       
  • Anonymous

    Anonymous - 2018-11-30

    A few queries hopefully relted to this topic

    1. how exactly do I change the config options i.e. which file do I edit and what editing has to be done e.g. are there lines to un-comment, be inserted etc?

    2. cobcun -r tells me that COB_SCREEN_EXCEPTIONS and COB_SCREEN_ESC are off yet PFKEYS are returning values fine ?? (I use ACCEPT xxx FROM ESCAPE KEY). The ESCAPE, as per the comments above, does not but using SET ENVIRONMENT commands at the start of a program has no effect hence the need to manually set this.

    3. I've just upgraded to cobc (GnuCOBOL) 3.0-rc1.0 which has addressed the "infinite loop with ACCEPT a single PIC X screen" . However when I now press FN with ESC - I have an HP pavilion and ESC is very close to F1 so easy to press - the programs crash with Windows telling me XXXXXXXX.exe has stopped working. Putting in a debug display immediately after an ACCEPT statement indicates that control is not returned to the program i.e. the ACCEPT statement is triggering the crash. (FN + ESC is the standard way of displaying HP (laptop) system info and caused no problems in the previous GnuCOBOL version).

    Many thanks

     
    • Simon Sobisch

      Simon Sobisch - 2018-11-30

      how exactly do I change the config options i.e. which file do I edit and what editing has to be done e.g. are there lines to un-comment, be inserted etc?

      Did you read the runtime.cfg? It should be clear, otherwise we should tweak it.

      I never heard of that the error with the extended function key. Please output infor of cobcrun --info to get a clearer picture of your environment.

       
      • Anonymous

        Anonymous - 2018-11-30

        Simon, it would be great if you could give typical steps showing how to enable a particular option for example say COB_SCREEN_ESC.

        Where is the SETENV command supposed to be issued? I've tried coding it as the first lines in the procedure division of a typical program but to no effect.

        Is the runtime.cfg file supposed to be edited?

        Re. cobcrun --info, is as follows....

        C:\Program Files (x86)\OpenCobolIDE\GnuCOBOL\bin>cmd
        Microsoft Windows [Version 10.0.14393]
        (c) 2016 Microsoft Corporation. All rights reserved.
        
        C:\Program Files (x86)\OpenCobolIDE\GnuCOBOL\bin>cobcrun --info
        libcob (GnuCOBOL) 3.0-rc1.0
        Copyright (C) 2018 Free Software Foundation, Inc.
        License LGPLv3+: GNU LGPL version 3 or later <http://gnu.org/licenses/lgpl.html>
        This is free software; see the source for copying conditions.  There is NO
        warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
        Built     May 10 2018 01:41:59
        Packaged  Apr 22 2018 22:26:37 UTC
        
        build information
        build environment        : i686-pc-mingw32
        CC                       : gcc
        C version                : (MinGW) "6.3.0"
        CPPFLAGS                 : -I/mingw/include
        CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char -Wall
                                   -Wwrite-strings -Wmissing-prototypes
                                   -Wno-format-y2k -U_FORTIFY_SOURCE
        LD                       : c:/gc30x-build/mingw/mingw32/bin/ld.exe
        LDFLAGS                  :
        
        GnuCOBOL information
        COB_MODULE_EXT           : dll
        dynamic loading          : system
        64bit-mode               : no
        BINARY-C-LONG            : 4 bytes
        extended screen I/O      : pdcurses: PDCurses 4.0.2 - Public Domain 2017-07-26
        variable format          : 0
        sequential handler       : built-in
        ISAM handler             : BDB, version 6.232
        mathematical library     : GMP, version 6.12
        
         

        Last edit: Simon Sobisch 2018-12-01
        • Simon Sobisch

          Simon Sobisch - 2018-12-01

          I personally think the best option would be to adjust runtime.cfg (just uncomment the options you want to set in, leave in the rest).
          Doing this the only setenv you may need to use is either set COB_CONFIG_DIR=C:\Program Files (x86)\OpenCobolIDE\GnuCOBOL\config and change runtime.cfg or set COB_RUNTIME_CONFIG=C:\test\gc_config1.cfg to explicit name a configuration file if you don't want to change the "system defaults" (which you set in the runtime.cfg placed in COB_CONFIG_DIR).

          If you compile your start program as module you can also just do:
          cobcrun -c C:\test\gc_config1.cfg YOURPROG which internally sets COB_RUNTIME_CONFIG.

          You can see the actual options used (including the current path to the runtime configuration file) with cobcrun --runtime (or cobcrun -c C:\test\gc_config1.cfg --runtime.

           
          • Anonymous

            Anonymous - 2018-12-03

            Changing the config options are now indeed recognised (cobcrun -info command shows this - see below) but the changes have no effect in that the function keys always work and the ESCAPE does not regardless of setting the options to true or false. Not a big problem as such but ESCAPE is useful key to have e.g. home / menu shortcut.

            What is a problem is that running with GnuCOBOL version 3.0-rc1.0 , pressing FN + ESC or F2 or F3 without the FN extension causes a "Windows XXXXXXXX.exe has stopped working" abend (in addition to doing what they should do i.e. give HP laptop system info and adjust the brightness). This does not happen with GnuCOBOL version 2.0.0 although the side effect with that version is the "infinite loop with ACCEPT a single PIC X screen"

            Looks like I'll either have to revert to version 2.0.0 and code double digit selection options on the menus or use version 3.0-rc1.0 and ask the users to make sure they don't adjust the brightness of their screens!

            cobcrun -info confirms the change to runtime.cfg have been recognised:

            Screen I/O configuration
                : COB_BELL              : BEEP (default)
                : COB_REDIRECT_DISPLAY  : false (default)
                : screen_esc            : false
                : screen_exceptions     : false
                : COB_INSERT_MODE       : false (default)
                : COB_TIMEOUT_SCALE     : 0 (1000) (default)
                : COB_LEGACY            : false (default)
            
             

            Last edit: Simon Sobisch 2018-12-03
            • Simon Sobisch

              Simon Sobisch - 2018-12-03

              I guess that's cobcrun --runtime. In any case: I cannot reproduce the crash using the same binaries, therefore I can't check why that chrash happens (I assume this is because the using screenio library gets "something" which it can't handle) but I don't know. I may be able to produce a new DLL for this PDCurses version with debug information (this may or may not help) and in any case a test of another variant like wingui would be also interesting...
              I should be able to come back to this soon. In the meantime: please register / login to remove the need for a manual moderation step (currently a living person needs to "accept" your posts as "not spam").

               

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.