Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Run A Program From Another One

Recommended Posts

I have written two programs. Lets call them MAIN and SMALL . Program SMALL is supposed to eventually go inside program MAIN. Problem is that if I put the code inside of it, it will be extremely hard to read. Can I just compile the program and run it from inside the main one ? I've heard that you could. Both programs use identical variables and I wrote it this way intending to cut and paste the code into the main one but if I can do this without cutting and pasting 150 KB worth of source code then I'd like to learn how. I'm coding in C++ and am using functions and pointers but I haven't learned classes or templates yet. The code from program SMALL is too big to make a function I think. What do you think I should do ?kvarnerexpress

Share this post


Link to post
Share on other sites

normally i'd stick it in a class or possibly a namespace (which is similar to a class). classes aren't too hard to get the hang of, there's heaps of free tutorials on the net about c++ classes. try functionX c++ tutorials @ http://www.functionx.com/cpp/index.htm. the link to the 'User-Defined Types and Classes' tutorial is in the column on the left under 'C++ objects'.

also you could probably do something like that with a DLL file, although i'm not too familar with them. i'm pretty sure that if you were to do it with a DLL, you would need to pass each variable as a seperate argument to the DLL or something like that.

overall i think using a class is your best option. it's also a fundamental part of the C++ language, so learning it will probably boost your skill / productivity / creativity a considerable amount.

ok good luck! :ph34r:

Share this post


Link to post
Share on other sites

I am not shure how to run program in c++ or VB, but in GML, this action is called 'execution'. In GML, you can execute program with one command: shell_execute ('filename');

Share this post


Link to post
Share on other sites

actually, there's probably a windows shell function call that could do that. to find it, you'd probably want to check out the MSDN documentation in the win32 section. if you have to use MFC or anything it would probably introduce alot of needless overhead, so try to avoid it.cheers (by the way thanks for that sobhan, you've helped me with that post too :huh: )

Share this post


Link to post
Share on other sites

one program cannot access the other programs variables (without accessing the memory directly) , but you could run the SMALL program by calling " System("SMALL.exe -param -param2 -param3"); but you would need to include <windows.h> to use the System() function. a better method would be to put the code from SMALL into a .cpp file and if you are using visual studio, if you include it in the workspace it will be compiled with the program.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.