Menu

CBL_GET_SCR_SIZE

2024-05-08
2024-06-05
  • Guido Rebry

    Guido Rebry - 2024-05-08

    Hi!

    I use Windows 10 version 22H2, GnuCOBOL package GC32M-BDB-x64 by Arnold Trembley, Windows Terminal with command prompt profile, font Cascadia Code size 10, codepage 850 and I have 236 columns and 66 lines on my screen.

    I would like to change the screen layout depending on the size of the screen.

    But... CBL_GET_SCR_SIZE gives (only) 20 columns and (the correct) 66 lines.

    See attached program MYSCREENSIZE.cob

    Am I doing something wrong or is it CBL_GET_SCR_SIZE?

     
  • Guido Rebry

    Guido Rebry - 2024-05-08

    Sorry, I forgot : I also use pdcurses-wincon.dll.

     
  • Guido Rebry

    Guido Rebry - 2024-05-22

    After 2 weeks more than 50 views but no reaction. Am I the only one with this problem?

     
  • Vincent (Bryan) Coen

    Change fields No-Of-Lines and No-Of-ColUMNS to PIC 999 value zero.

    Then try again.

    Just in case bin-char is being truncated and there is no reason for using binary any way and removes the need for the intermediate move.

     
    👍
    1
  • Guido Rebry

    Guido Rebry - 2024-05-23

    This is not what is written in

    "GnuCOBOL Programmer’s Guide For Version 3.2 [28 July 2023 at 234:55 GMT.] and for 4.0 (partial & tentative only)"

    point "8.2.36. CBLGETSCRSIZE".

    Anyway, I changed the program as you suggested and it doesn't work. Now both the number of lines and the number of columns are wrong.

    See attached png file.

     
    • Eugenio Di Lorenzo

      Could you test if it works with ACCEPT?
      See Programmers Guide at 7.8.1.6 ACCEPT FROM Screen-Info

      example:

      01 wLINES   pic 9(03).
      01 wCOLUMNS pic 9(03).
      ...
      ACCEPT wLINES   from LINES
      ACCEPT wCOLUMNS from COLUMNS
      
       
  • Eugenio Di Lorenzo

    ACCEPT works fine. GET_SCR_SIZE fails.
    see attached screenshot and attached program

     

    Last edit: Eugenio Di Lorenzo 2024-05-23
  • Guido Rebry

    Guido Rebry - 2024-05-23

    You are absolutely right Eugenio, accept works fine, get_scr-size fails.
    But I want to know the screen size without pushing a key.
    I don't think that is possible with an accept. Am I right?

     
  • Guido Rebry

    Guido Rebry - 2024-05-23

    No, I'm wrong. Omit the "accept omitted" in the program and that's it. Thanks!

     
  • Vincent (Bryan) Coen

    The program works under Linux in both cases with and without the accept omitted but I did modify the display line64,65 & 66 lines to :

    in WS :

    01 wlines-1 pic 999.
    01 wlines-2 pic 999.
    01 wlines-3 pic 999.

    at end block of 1st displays :

    subtract 1 from no-of-lines giving wlines-1.
    subtract 2 from no-of-lines giving wlines-2.
    subtract 3 from no-of-lines giving wlines-3.

    display "line64" at line wlines-1 col 001 end-display.
    display "line65" at line wlines-2 col 001 end-display.
    display "line66" at line wlines-3 col 001 end-display.

    It could just be that "CBL_GET_SCR_SIZE" does not work in windoz, at least as you have installed it etc.

    With the accept omitted in place I changed the width of terminal wider after the 1st display block and then pressing return and the 2nd display shows correct values.
    This was using terminal program QTerminal v1.4 in Mageia v9 X64.

     
  • Eugenio Di Lorenzo

    The presence or absence of ACCEPT OMITTED has nothing to do with it.
    I believe a bug ticket should be opened for CBL_GET_SCR_SIZE.

     
    👍
    1
  • Ralph Linkletter

    Until the bug is resolved would an environment variable suffice?
    SET / EXPORT SCR_SIZE=24x80, 132x43. . .

     
  • Eugenio Di Lorenzo

    I think someone should open a bug ticket for the above documented incorrect behavior of CBL_GET_SCR_SIZE

     
  • Chuck Haatvedt

    Chuck Haatvedt - 2024-06-03

    the CBL_GET_SCR_SIZE and CBL_SET_SCR_SIZE functions are implemented using the CURSES functionality. So if a CURSES window has not been iniitialized by using extended screen i/o functionality it will fail.

    We could discuss with Simon to determine the appropriate behavior when these fuctions encounter this condition.

    Chuck Haatvedt

    ps... I've worked on the implementation of these so I'm somewhat familiar on how they work under the covers.

    I'll do some testing of this when I get some time.

     

    Last edit: Chuck Haatvedt 2024-06-03
  • Anonymous

    Anonymous - 2024-06-04

    The very first statement in program myscrnsize2.cob is :
    "display " " erase eos at 001001 with background-color 0 end-display."
    so initialization is done. Right?

     
  • Chuck Haatvedt

    Chuck Haatvedt - 2024-06-05

    The programmers guide is incorrect, the format should be

    01  NO-OF-LINES             USAGE BINARY-CHAR UNSIGNED.
    01  NO-OF-COLUMNS           USAGE BINARY-CHAR UNSIGNED.
    

    the value of binary 236 in a signed field is Negative 20

    when corrected it displays as it should

     

    Last edit: Chuck Haatvedt 2024-06-05
  • Eugenio Di Lorenzo

    ok. thanks for the solution !
    now we need to open a bug ticket for the programmers guide.
    I will take care of it.

     
  • Chuck Haatvedt

    Chuck Haatvedt - 2024-06-05

    Also there should be an explicit warning that this function will not deliver the correct results if the lines or columns exceed 255.

    I'm considering to have the function inspect the variables passed from COBOL and work with BINARY-SHORT UNSIGNED as an option. I still need to do some analysis of this potential option.

            Chuck Haatvedt
    
     
  • Guido Rebry

    Guido Rebry - 2024-06-05

    Perfect!

     

Anonymous
Anonymous

Add attachments
Cancel