Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Run A Program From Another One
kvarnerexpress
post Sep 24 2005, 10:42 AM
Post #1


Super Member
*********

Group: Members
Posts: 407
Joined: 13-December 04
Member No.: 2,696



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
Go to the top of the page
 
+Quote Post
switch
post Sep 25 2005, 04:07 AM
Post #2


Premium Member
********

Group: Members
Posts: 178
Joined: 13-October 04
From: NSW, Australia
Member No.: 1,713



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 @ 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! biggrin.gif
Go to the top of the page
 
+Quote Post
sobhan
post Oct 2 2005, 02:20 PM
Post #3


Newbie [Level 1]
*

Group: Members
Posts: 21
Joined: 1-October 05
Member No.: 12,412



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');
Go to the top of the page
 
+Quote Post
switch
post Oct 4 2005, 11:38 AM
Post #4


Premium Member
********

Group: Members
Posts: 178
Joined: 13-October 04
From: NSW, Australia
Member No.: 1,713



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 biggrin.gif )
Go to the top of the page
 
+Quote Post
sharpz
post Nov 16 2005, 11:41 PM
Post #5


Member [Level 1]
****

Group: Members
Posts: 67
Joined: 16-November 05
Member No.: 14,373



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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Stop A Program Excecution(4)
  2. Program Flow(2)
  3. Timeouting Program(2)
  4. Crazy Looking C Program(19)
  5. C++(15)
  6. Program From Mekka 97 4k(2)
  7. Need Debugging Help For A Simple Program(3)
  8. Need Help With C Program To Test If A Number Is Prime(12)
  9. Executing An Exe From Within A Program!(7)
  10. My First C++ Program(6)
  11. Source Code For Paint Like Program Under Dos In C(2)
  12. Program Lang I Know(2)
  13. Centering The Text In A Simple C++ Program?(8)
  14. Buffer Overflow In Action Tutorial(0)
  15. C Or C++ Easy Programming Generator(6)
  1. A C++ Program Print Hello With Nothing Written In Main() Method(2)
  2. A Crazy Program In C(13)
  3. How To Run A Process Through Your Program (c#)(0)
  4. Any Program Ideas?!(5)
  5. If/else Demo Program Bug(4)


 



- Lo-Fi Version Time is now: 6th September 2008 - 01:28 AM