Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Exchange data (variables) between two running programs?

Author
Message
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 2nd Apr 2013 17:34
I have two programs, a map editor and an event editor. I want to pass information on to the event editor from the map editor. They are both EXE's created with DBP. And I would like to be able to call (startup) the event editor exe with parameters also (for the first time the map editor passes data on the event editor, in case it is not already running). Is this possible?

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 2nd Apr 2013 17:45
TCP/IP or UDP protocols is what you need
its local sending data from app to app. very usefull..

the best choice for you is to use TCP/IP connection..

setting up the server/client to local, and that way u can pass values/strings or whatever u want from app to app.

Advanced Updater for your games!
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 2nd Apr 2013 18:07
You could try writing the variables to an output file from one application and loading them into the other.

D.D.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Apr 2013 19:00
Connect to the loopback address: 127.0.0.1 to pass data between apps.

To launch an application with commands, use commandline options.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Apr 2013 19:19
Quote: "You could try writing the variables to an output file from one application and loading them into the other."


If you want to shorten the life of your HDD then yes, that might work.

A much more recommended solution is to use some form of networking and connecting to 127.0.0.1 (localhost).

TheComet


Level 91 Forumer - 9600 health, 666'666 keystroke power (*2 coffee)
Abilities: sophisticated troll, rage
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 2nd Apr 2013 19:21
I will try Derek Darkly's output file first, that was how I wanted to do it in the first place but just wondered if there was a more direct solution.

@Mobiius: How do I read the commandline options?

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Apr 2013 20:17 Edited at: 2nd Apr 2013 20:19
There's also file mapping commands; additionally, you can also share memory banks using the Matrix1 mutex commands; I haven't tested the speed difference between local TCP, but sharing memory is really fast. The other way is to share windows messages. For general purpose however, TCP or file mapping should be easiest to grasp.

Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 2nd Apr 2013 20:19 Edited at: 2nd Apr 2013 20:19
Quote: "I will try Derek Darkly's output file first, that was how I wanted to do it in the first place but just wondered if there was a more direct solution."

his way wont work..

Quote: "If you want to shorten the life of your HDD then yes, that might work."

TheComet is right

also note that you CANNOT access open same file 2 times; specialy when the file is Opened to WRITE.
you cant open to read it again.. it wont work.

so his way wont work.

Advanced Updater for your games!
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Apr 2013 20:24
Quote: "also note that you CANNOT access open same file 2 times; specialy when the file is Opened to WRITE.
you cant open to read it again.. it wont work."


You can if you install Matrix1 and poll the file state using the command: Result = FILE IN USE ( Filename )

Sometimes it is necessary to exchange information between files; but as stated before, networking would be better; and like I said, memory sharing, windows messages and file mapping are common methods.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Apr 2013 21:11
Don't use a file to share information. Just don't! lol

As for the command line, from the help file:
Quote: "CL$
This command will return the string passed in as a command line when the program is run as a standalone executable.

Syntax
Return String=CL$()
Returns
The return value is a string.

Description
When this program is created as an executable file, any additional parameters entered after the executable name are treated as a single command line string. You can use this string to control how your executable behaves based on the contents of the string.

Example Code
PRINT CL$()"


Call the executable file like so: Program.exe switches

CL$ will return "switches"

It's up to you to decide what these command line switches will be, and how you will split them, but this is a start.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Apr 2013 21:45 Edited at: 2nd Apr 2013 21:47
Guys. Guys. A file? FILE?!

ARE YOU PEOPLE ACTUALLY SUGGESTING IT'S GOOD PRACTICE TO USE A FILE?!?



TheComet


Level 91 Forumer - 9600 health, 666'666 keystroke power (*2 coffee)
Abilities: sophisticated troll, rage
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Apr 2013 21:59 Edited at: 2nd Apr 2013 22:02
@cybermind
If you use a memblock, you can grab the pointer from that and just write data back and forth to the memory pointer. Just make sure the memblock is large enough to store the data you want to share.

Does DBPRO have clipboard commands? That would be another way. You can access clipboard commands through a Win API call if it's not a function driectly available in DBPro.

Enjoy your day.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Apr 2013 22:20
Quote: "Does DBPRO have clipboard commands? That would be another way. You can access clipboard commands through a Win API call if it's not a function driectly available in DBPro."


I personally wouldn't go down that route. Imagine how annoying it would be if you couldn't copy/paste image URLs or whatever when the program is running.

TheComet


Level 91 Forumer - 9600 health, 666'666 keystroke power (*2 coffee)
Abilities: sophisticated troll, rage
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Apr 2013 22:44 Edited at: 3rd Apr 2013 00:17
Oh my word.

Come on guys, read the messages; I said sometimes you need to exchange information with files. So it is wrong to say "it won't work" I also said to use TCP, memory or file mapping; (file mapping is obviously not the same thing as opening a file.... ). It seems like I should start writing my messages with caps-lock on or something.

Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 2nd Apr 2013 22:45
Quote: "If you want to shorten the life of your HDD then yes, that might work."


Not saying that mine is the best solution, however, if Cybermind is only switching between applications every few minutes or so, it shouldn't be too taxing on the HD. The information doesn't have to be written every time a variable changes. (See below)


Quote: "also note that you CANNOT access open same file 2 times; specialy when the file is Opened to WRITE.
you cant open to read it again.. it wont work."


Until Cybermind can research your method, Sergey, or until someone can help out with more specific code, a simple method could be to add (to both apps) a 'WRITE FILE' feature which writes all current data once and closes the file, and a 'READ FILE' feature to load it.

Again, I'm not saying that this is a better way, just something that could be quickly coded with little knowledge...

There are many programmers here with skills superior to mine, I just try to help out those like me who aren't experts yet!

D.D.
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 3rd Apr 2013 12:59
It is not that hard to write the network code. I have made made small network games before which were client\server based. So I think I will give it a shot today

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 4th Apr 2013 03:28
Read up on the Matrix1 Mutex commands like Chris Tate said. The plugin includes functionality to create "shared" variables that you can access between programs.

Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 4th Apr 2013 17:01
Ah well, I already made the network code work

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...

Login to post a reply

Server time is: 2026-07-06 20:51:59
Your offset time is: 2026-07-06 20:51:59