× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Courtesouy of Mr. Cozzi,
Here is link to article:

http://www.systeminetwork.com/artarchive/newsletter/w/1001/i/6825/a/55579/index.html

HTH

Retrieving the Current Display Size in RPG IV
by Bob Cozzi



September 19, 2007 —

RPG-XML Suite Create XML Web Services from RPG! NO Java! NO Websphere!
With RPG-XML Suite, RPG programmers have all the tools necessary to
compose, transmit and parse XML — without ever leaving RPG! Offer a web
service on your System i or call a web service easily on a remote machine
with RPG-XML Suite. Download your risk-free 30 day trial today at
www.rpg-xml.com!



Return Current Display Mode and Screen Dimensions
Back in the later days of the System/38, IBM started working on a set of
Windowing APIs for the 5250 display files. Those APIs, called Dynamic
Screen Manager (or DSM), include a set of dozens and dozens of APIs that
do more than you can ever want to do.

Two of those APIs are used regularly in my old green-screen code. I use
them to determine the current size of the display. It's the old *DS3 vs.
*DS4 mode dilemma, where you need to output a display format based on the
current display mode.

The first API is QsnRtvMod. This API retrieves the current display mode (3
or 4) and returns that value to the caller. When DSM was being created,
IBMers on the project couldn't for the life of them figure out where the
current display status was kept. Hearing about this, I used my experience
with MI and the internals of the System/38 and AS/400 to narrow down where
it might be located. I then checked with an IBM Rochester engineer, who is
still to this day one of the smartest people I've ever met.

He confirmed that I was on the right track and actually figured out how
the Toronto programmer should go about retrieving that value. I forwarded
it on to the programmer and, needless to say, this seemingly simple
capability was needlessly complex and mysterious.

But the good news is she created QsnRtvMod to easily retrieve the display
mode, regardless of the underlying complexities. The prototype for
QsnRtvMod follows:

D QsnRtvMod PR extProc( 'QsnRtvMod ')
D mode 1A
D llHandle 10I 0 Const OPTIONS(*OMIT)
D error 16A OPTIONS(*VARSIZE)
The API returns the current display mode to parameter 1. Specify a
one-position character field to return the mode, for example:

D DS3_mode C Const( '3 ')
D DS4_mode C Const( '4 ')
D mode S 1A
D errDS S 16A Inz(*ALLX '00 ')

/free
QsnRtvMod(mode : *OMIT : errDS);
if (mode = ds3_mode); // Normal mode
elseif (mode = ds4_mode); // Wide-screen mode
endif;
/end-free
The second parameter needs to be *OMIT, and the third parameter is the
traditional API error data structure. I like to pass all hex zeros for
this parameter so that the APIs ignore the parameter. It would be nice if
we could just pass in the mode parameter, but that's why they make
subprocedure wrappers.

The other API is a bit more specific on the display mode status.
QsnRtvScrDim returns the current screen dimensions. So, for example, it
returns 80:24 or 27:132.

The prototype for QsnRtvScrDim follows:

D QsnRtvScrDim PR 10I 0 extProc( 'QsnRtvScrDim ')
D rtnRows 10I 0
D rtnColumns 10I 0
D llHandle 10I 0 Const OPTIONS(*OMIT)
D error 16A OPTIONS(*VARSIZE)
The first parameter receives the current number of rows on the display;
the second parameter receives the number of columns on the display. As in
the other API, the low-level environment handle and API error data
structure are ignored for our purposes.

Calling QsnRtvScrDim is simple, for example:

D rows S 10I 0
D cols S 10I 0
D mode S 1A
D errDS S 16A Inz(*ALLX '00 ')

/free
// Retrieve the rows and columns currently displayed
QsnRtvScrDim(rows : cols : *OMIT : errDS);
if (rows = 27 and cols = 132);
// Wide-screen mode
endif;
/end-free

The DSM APIs all begin with the letters 'Qsn' and can be located with the
IBM API Finder. These two APIs only scratch the surface as to what you can
do with them. One key point, as I've implied throughout this article, is
that if you pass *OMIT for the low-level API, or pass in all hexadecimal
zeros, the current display is used rather than a DSM environment virtual
screen.

A great test program to write is to call both of these APIs in an RPG IV
program and write the result to the joblog. Then assign the program to the
attention key (SETATNPGM) and press ATTN while on Command Entry, then
display a spool file (which will switch the display to 27x132 mode), and
hit ATTN again. Then go look at the entries in the joblog. It is a pretty
cool capability -- one that I used back in the 1980s when I wrote the
first windowed 5250 application in 1984. It was called 'Partner ' and was
a 5250 clone of the popular PC DOS SideKick application from Borland
International.

I still have people using it or portions of it to this day, and it still
works. Can you say that about any Windows-based application from 20+ years
ago?

Ron Power
Programmer
Information Services
City Of St. John's, NL
P.O. Box 908
St. John's, NL
A1C 5M2
709-576-8132
rpower@xxxxxxxxxx
http://www.stjohns.ca/

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.