Using QSNRTVMOD to find the last displayed screen size

While I was writing that previous blog about handling wide fat screens I stumbled across another useful API (QSNRTVMOD) for retrieving the current screen mode that we are displaying. This means we could find our screen width programmatically. Why isnt that a word?

I’m not too sure why anyone would want to do this but… in the spirit of sharing stuff on the same theme as the widescreen gubbins I was mumbling about earlier…

We can find out if we are displaying a 24×80 or a 27×132 screen with this little gem:

QSNRTVMOD

The QueueueuSinnerTeevumMod API will return a code and tell us what screen format we are using in our 5250 session.

We can add some error handling to the RPG program without changing any DDS in our *DSPF..

Procedure – Retrieve the Screen Mode

// +------------------------------------------------------------------+
// | Procedure to retrieve current screen mode ('3'=24x80 '4'=27x132) |
// +------------------------------------------------------------------+
QSNRTVMODdcl-proc #RtvScrnMode export;
  dcl-pi #RtvScrnMode char(1) end-pi;

dcl-s currentScrnSize char(1) inz('0');

dcl-ds myApiError inz qualified;
  Bytes int(10) inz( %size( myApierror ));
  BytesAvailable int(10) inz;
  ErrorID char(7) inz;
  Reserved char(1) inz( x'00' );
  MessageData char(128) inz;
end-ds; 

dcl-pr QsnRtvMod extproc( 'QsnRtvMod' );
  *n char(1); // DspMode
  *n int(10) options( *omit ); // Handle
  *n options( *omit: *varsize ) like( myApierror ); // ErrorDS
end-pr;

QsnRtvMod ( currentScrnSize
          : *Omit
          : *Omit 
          );

// Too lazy to add error handling for 'myApiError' but you could do that here

Return currentScrnSize;

end-proc;

(obviously this code should be in a service program to make it reusable but for code readability in this blog I’ve copy/pasted it separately)

Mainline – Check screen size before doing something

So, now we just need to check our screen size before doing something.

I’m not too sure if this is ever helpful technique really… I mean I have never had to use it in anger… but that doesnt mean that somebody out there might be looking for exactly this solution 🙂

// Procedure to retrieve current screen mode (3=24x80; 4=27x132)
If RtvScreenMode() = '3';
  // do some stuff for 24x80 screens
If RtvScreenMode() = '4';
 // do some stuff for 27x132 screens
else;
  // do some error handling stuff or perhaps handle totally weird screen sizes
endif;

*inlr = *on;

NOTE: This API is telling you the last screen size displayed not the screen size that the 2520 terminal is capable of. In other words – if you are logged into a 27×132 terminal but displaying a 24×80 screen and run this code it will tell you its 24×80. Go to a main IBM i menu like (GO MAIN) and it will say it’s 24×80 but call it from a widescreen format (like SEU-WIDE for example) and it will tell you it’s 27×132

Comprendez?

(0 votes) 0/10