Menu

Detecting winw (screen) size from Regina Rexx 3.93

2020-01-02
2020-02-11
  • Wesley Struebing

    I'm looking for a way from Regina Rexx (latest incarnation of 10-14-2019) to detect the size of the window a Rexx script in executing in. I saw one routine using a PARSE VALUE SCRNSIZE construct, but I just get back that scrnsize isn't a recognized command or instruction under Regina Rexx. Help? Thanks!

     
  • Gerard Schildberger

    That should be SCRSIZE.

    R4, PC/REXX, Peronnal REXX, and ROO all support the SCRSIZE BIF.

    I uploaded a SCRSIZE (function). I hope I included enough boilerplate to catch most errors.

    It handles old versions of DOS as well.

    It has a little more boilerplate than needed, but it can't hurt to check for errors.

    Gerard Schildberger

     
  • Gerard Schildberger

    Uploaded a SCRSIZE.REX (function).

     
  • Gerard Schildberger

    To use:

     parse value  scrsize()   with  sd  sw  .
     say 'sd='  sd
     sqy 'sw='  sw
    
     
  • Gerard Schildberger

    Uploaded a better version of SCRSIZE.REX

     
  • Gerard Schildberger

    Upload a fuller version with more error checking and better error messages.

     
  • Wesley Struebing

    Gerald;
    Thank you! I'm working on a rotine that outps dat with "pagebreaks", and it is currently coded for a specific size. I want to recode it to use current window size to do a dynamic "press enter to continue" followed by a screen clear. This will help immensely.

     
  • Paul Kislanko

    Paul Kislanko - 2020-02-10

    A slight fly in the ointment is that on Windows 10 SD (screen depth) is buffer-size, not window-size. So on my system I'd get a "press enter to contiue" every 9001 lines.

    mode
    
    Status for device CON:
    ----------------------
        Lines:          9001
        Columns:        197
    

    My (maximized) window has 52 lines of text, so I'd want a "pause" after 51. I haven't found a way to get the window size in text-lines yet, but if I do find one it will likely not be downward-compatible.

     
    • Brian Tiffin

      Brian Tiffin - 2020-02-11

      How about http://rexxcurses.sourceforge.net/index.html and (from the Hello, world sample)

      Call RxFuncAdd 'CurLoadFuncs','rxcurses','CurLoadFuncs'
      Call CurLoadFuncs
      Call CurInitscr
      Call CurCbreak
      /* display "Hello World" in the middle of the screen */
      row = LINES / 2
      col = COLS / 2 - 6
      Call CurMove row, col
      Call CurAddstr "Hello World"
      Call CurMove LINES-1, 0
      Call CurAddstr "Press any key to continue..."
      Call CurRefresh
      key = CurGetch()
      Call CurEndwin
      Return
      

      Might be a lot more than you need, Paul, Wesley, and you'll have to deal the the RMCUP and SMCUP terminal shadow screens, but you'll have access to all kinds of terminal user interface potential with Rexx/Curses. From that sample it looks like it should just be LINES and COLS. I've only tried on GNU/Linux nodes (only tried, not really used beyond "that works"), but Rexx/Curses also builds with the Windows friendly PDCurses. https://pdcurses.org/ with work occurring at https://github.com/wmcbrine/PDCurses I'm not sure how involved Mark is with PDCurses now, but he was and still is, as far as I know.

      Can't say you won't bump into the same problem of window vs buffer size, but I'm wagering that LINES is based on window size, not the scroll back buffer length. And you may have to deal with any resizing after an CurInitScr to properly reset the Regina view of the LINES COLS and COLORS variables.

      And a nice bit of script from Gerard. By happenstance., bumped into this very thing (Gerard's SCRSIZE Rexx library entry) on Rosetta Code just yesterday. Gee, I wonder if this led to that, or that led to this, or if the world really is that small. :-)

      Have good, make well,
      Blue

       
  • Wesley Struebing

    Hey, Brian (Blue?);

    This is much more information than I expected! <grin></grin>

    I have downloarded both RXCurses (it seems it contains a bunch of Rexx scripts, but it needs a curses library, which I presume is provided by compiling/making PDCurses?
    If that's the case, is Pelles C a decent free C compiler?
    As Paul comments on Gerard's SCRSIZE routine, it does indeed show buffer size, not actual screen size.
    I suspect that world is really that small :-D

    Wes

     
    • Brian Tiffin

      Brian Tiffin - 2020-02-11

      Hi, Wesley. Nickname is Bluey actually, but I'm lazy. ;-)

      Hrrmm, If this is for Windows, then I'd have to wait for someone with a little more experience. I happened to look the other day. I removed the last remnants of Microsoft from my dev machines back in 2013. I'm pretty much out of that loop now.

      From listening to the struggles that some of the GnuCOBOL users go through with getting free software builds on Windows machines, there is a choice of Visual Studio (which most seem to think is bloated, but it's pure native to the platform and cost free), MSYS MinGW or Cygwin.

      MSYS and MinGW is a set of "Min"imal ports for GNU software on Windows. gcc, autonconf and the other POSIX development tools.

      Cygwin is a custom shell that is pretty much a full on POSIX layer for Windows.

      When I still had a Windows partition, Cygwin was the first thing installed. bash and the like, with setup.exe for installing packages (lots and lots available). In Cygwin bash, you grab a source package (usually a gzipped tarball), extract it and ./configure; make to get builds from source.

      I have zero experience with building from VS or MSYS.

      The new Bash on Windows might also be an option, Wesley. Never tried it so I'm not even sure what it looks like.

      I either install from main repositories or build from source on my Fedora and Xubuntu nodes, and am not a fan of taking random binaries off the net, but if you get stuck I might be able to ask a few trusted associates for pre-built PDCurses dlls and could post a link here. There will be other sites with precompiled PDCurses for Windows, but, unless there is an established trust, not recommended.

      Aside: The current trend seems to be "what? just run this unvetted code I'm sending you over the network" with most web sites now requiring Javascript. So maybe the world is just a place where you stick out your hand, and accept the offerings, good, bad or ugly. And eventually we'll all be trained to just go around licking random door knobs, because hey, why not. :-)

      Sorry I can't really help more than that, Wesley. Not much of an answer sadly.

      But, you know what? If I know Gerard, and I don't really, other than indirectly through all the good how-to code he posts on Rosetta Code; I'm going to wager some nerd cred that with the juicy problem of cyphering between window size and scroll buffer size, he'll have code posted in SCRSIZE.rex with a pure REXX solution to this problem. Might just take a little patience while he figures out some magic and shares a solution. Or not.

      Have good, make well,
      Blue

       

Log in to post a comment.