07-11-2024, 10:46 PM
The first post was a very simple example of how you'd use two programs and have them communicate with each other, to produce a "multi-screen" program. Below is a better example of this process at work, for those who might be interested in just running ONE program and letting it produce the multi-screens and handle everything for us.
Note that this is a little different than before. Here, you just run this program and it'll handle making both screens and interacting with them.
Also notice that once you _EXIT from one screen, it'll also automatically exit from the other screen as well.
Two screens, working together for one program, and both ending at the same time.
It this *isn't* a "multi-screen" program, I don't know what the heck it might actually be classified as.
Code: (Select All)
DIM SHARED AS LONG x, y, r, nul, client
SCREEN _NEWIMAGE(640, 480, 32)
host = _OPENHOST("TCP/IP:7319") ' no host found, so begin new host
IF host THEN
_SCREENMOVE 0, 0
SHELL _DONTWAIT COMMAND$(0)
DO
IF client = 0 THEN
client = _OPENCONNECTION(host) ' receive any new connection
ELSE
x = x + 2: IF x > 1280 THEN x = 0
CLS
_PRINTSTRING (x, y), "Steve is Amazing"
IF x > 1280 - _PRINTWIDTH("Steve is Amazing") THEN _PRINTSTRING (x - 1280, y), "Steve is Amazing"
_DISPLAY
_LIMIT 30
IF _EXIT THEN x = -1: y = -1
SendXY: GetXY
IF x < 0 THEN SYSTEM
END IF
LOOP
ELSE
_SCREENMOVE 640, 0
client = _OPENCLIENT("TCP/IP:7319:localhost") ' Attempt to connect to local host as a client
DO
GetXY
CLS
_PRINTSTRING (x - 640, y), "Steve is Amazing"
_DISPLAY
_LIMIT 30
IF _EXIT THEN x = -1: y = -1: SendXY
IF x < 0 THEN SYSTEM
LOOP
END IF
SUB SendXY
PUT #client, , x
PUT #client, , y
END SUB
SUB GetXY
GET #client, , x
GET #client, , y
END SUB
Note that this is a little different than before. Here, you just run this program and it'll handle making both screens and interacting with them.
Also notice that once you _EXIT from one screen, it'll also automatically exit from the other screen as well.
Two screens, working together for one program, and both ending at the same time.
It this *isn't* a "multi-screen" program, I don't know what the heck it might actually be classified as.