Get the current screen size
[Autolink] Menu
/* sample routine to get the current screensize for textmode windows */
/* without using REXXUTIL functions. */
parse value GetDisplaySize() with columns rows
say "The current OS/2 window size is " || ,
rows || " rows and " || columns || " columns."
exit 0
/* ------------------------------------------------------------------ */
/* function: Get the current display size */
/* */
/* call: GetDisplaySize */
/* */
/* returns: columns rows */
/* */
/* note: This function works only for display sizes up to 200 for */
/* columns or rows. The upper left corner is 1,1. */
/* The REXXUTIL function SysCurPos uses zero based values */
/* (the upper left corner is 0,0). */
/* */
GetDisplaySize: PROCEDURE expose thisPos
usedChars = ":;<=>?@ABCD"
/* save current cursor position */
rc = CharOut(, D2C(27) || '[' || "6n")
pull curPos
/* try to set the cursor to the position 200,200 */
rc = CharOut(, D2C(27) || '[' || "200;200H" )
/* get cursor position */
rc = CharOut(, D2C(27) || '[' || "6n")
pull tPos
/* restore current cursor position */
rc = CharOut(, substr( curPos,1, length( curPos)-1) || "H" )
/* v2.30 */
parse var tPos 3 y1 +1 y2 +1 3 rows +2 6 x1 +1 x2 +1 6 cols +2 .
if pos( y1, usedChars ) <> 0 then
rows = 10 || y2
if pos( x1, usedChars ) <> 0 then
cols = 10 || x2
RETURN cols rows
[Back: Get the current cursor position]
[Next: Redefine some keys]