Get Screen Dimensions in RB for Linux

new BookmarkLockedFalling
donnybowers
Junior Member
**

donnybowers Avatar

My website was created in the mid 2000s. Unfortunately I lost the code somehow.
Posts: 70Male

Post by donnybowers on Jun 25, 2021 18:45:24 GMT -5

This program might be useful for customizing things for your own personal use. I don't know if this would give a remote user of RB the correct information. I suspect it wouldn't, but let me know if you find out it does. I have no way of testing this right now. It would be interesting to know if it will report the screen dimensions of remote users or only the screen dimensions of the server host machine.

I will be using the information this code produces for custom styling of personal programs as well as possibly CMS type back-end programs for doing admin stuff. (If I find out it works for remote users then I will probably build some version of code into most of my programs to customize my pages for users of various devices and computer monitors.)

Of course most of us know our screen dimensions, but this code could be handy for when you have to transfer your RB programs to a different machine or if you change your monitor. You could have this information built right into your programs so that they will adjust according to different screen dimensions.

I've only tested this code on one system which is a Linux Puppy called UPupFF+D, built from Ubuntu 32bit Focal Fossa (LTS 20.04), some Debian Bullseye/Buster components and Kernel 5.4.x 32-bit PAE. Please share how it works if you try it on your system.

I'm pretty sure similar code could be developed for the Windows version of RB.


'PUBLIC DOMAIN CODE
ender=0 : mode=1
temp$ = shell$("xdpyinfo | grep dimensions")
print "Step 1:"
print temp$
print "Step 2:"
length=len(temp$)
temp$=right$(temp,ドルlength-17)
print temp$

print "Step 3:"
for i=1 to length
char$=mid$(temp,ドルi,1)
if char$="x" then char$="" : mode=2
if char$=" " then ender=1
if ender=1 then goto [skipper]
if mode=1 then width$=width$+char$
if mode=2 then height$=height$+char$
[skipper]
next i
print "Screen Width: ";width$
print "Screen Height: ";height$

'SAVE SCREEN WIDTH AND HEIGHT TO FILE
open "screen-dimensions.txt" for output as #1
print #1, width$
print #1, height$
close #1




Last Edit: Jun 25, 2021 19:17:06 GMT -5 by donnybowers
Any code I share on this forum is released to the public domain and may be used freely any way you like unless for some reason I specifically indicate otherwise in the post.
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

Post by StefanPendl on Jun 27, 2021 13:58:23 GMT -5

This will only work on Linux hosts and will display the screen size of the server host, not the client.
You will have to retrieve the size of the browser window, since the screen size is not used if the browser does not run full screen.

See www.w3schools.com/jsref/obj_window.asp for more information.

See runbasic.proboards.com/thread/1425/height-frame-screen-resolution-sc for example code.
[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM