@bplus i think, you talk about COMMON SHARED between two programs. Then is really possible runing more EXE files (windows), and run it with shared variables between this two or more programs. It is somewhere in forum...
@bplus i think, you talk about COMMON SHARED between two programs. Then is really possible runing more EXE files (windows), and run it with shared variables between this two or more programs. It is somewhere in forum...
(...) but on the other hand, at least it's fun here, isn't it?
:)
In that case, I'd use OPENHOST and OPENCLIENT to form a TCP/IP connection between the two programs, ofwhich there are several examples already here on the forums via chat hosts and clients.
TCP/IP between two programs on the same machine?
Interesting...
A lot of folks are curious about how we can get our programs to talk to each other, and curious about how we'd use QB64 to communicate via TCP/IP over a network. The wiki has a few examples, but they tend to be outdated and simply don't work for me. (Such as the mini-messenger example here: http://www.qb64.org/wiki/OPENHOST.) I figured people might like a working example of how to get all the proper parts working together, so I tried various wiki samples and eventually decided to rework one until I got it to working for me...
The finished code here is working as intended on Windows. (I dunno if it'll work for Linux or Mac users, but I'd love to hear if it does or doesn't.) Instead of a single set of code which tries to toggle between client and host, I worked this up as two separate sets of code -- one for each. Copy one set of code into QB64, and then run it. Then, while that program is still running in the background, copy the second set of code and run it.. Type in either program and watch as they happily communicate with each other without any issues.
THE HOST:Code: QB64: [Select]
PRINT "[Steve's Mini Messenger]" PRINT "[Beginning new host chat session!]" NumClients = 0 'PRINT #client, myname$ + " connected!" PRINT "[Chat session active!]" PRINT "ERROR: Could not begin new host!" DO ' host main loop NumClients = NumClients + 1 Users(NumClients) = newclient PRINT "Welcome to Steve's Mini Messenger!" GetMessage Users(i) 'check all clients for a message NEXT i SendMessage myname$, mymessage$, client _LIMIT 30 k$ = INKEY$ mymessage$ = myname$ + ":" + mymessage$ mymessage$ = ""
THE CLIENT:Code: QB64: [Select]
Have fun playing around with this as a local system messenger program. Try it out, kick it around, and let me know if there's anything you don't understand about what it's doing. This isn’t exactly how I'd normally write one of these; but that's because I started with what the wiki had and then gutted it and rebuilt it up until it was actually working for me as it should. Honestly, I think I would've been better off to have just wrote the whole program from scratch! :P