Thread: Accessing Separate Program without Closing Immediately

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    5

    Accessing Separate Program without Closing Immediately

    I'm developing a realtime data acquisition program. I have gotten the data to be acquired realtime from an analog source and output to a .csv file. I am now using the API LiveGraph to graph this data in realtime. Works well. My problem is that I want my program to automatically open LiveGraph and the file when it begins. However, I'm only familiar with the system() command, which closes the program immediately after opening it. When dealing with GnuPlot, one had to put pause -1 at the end of the GnuPlot code. Is there an easier, more efficient way to open the program, or does anybody know of a way to keep it open using the system() command. Code looks like this:
    Code:
    #include <iostream>
    using std::cerr;
    using std::endl;
    #include <windows.h>
    #include <cbw.h>
    #include <stdio.h>
    #include <conio.h>
    #include <fstream>
    using std::ofstream;
    #include <cstdlib>
    
    using namespace std;
    
    int main()
    {
    	int I;
    	int J=0;
    	int L=0;
    	int BoardNum=0;
    	int ULStat=0;
    	int LowChan=0;
    	int HighChan=0;
    	int Gain=BIP5VOLTS;
    	long Count=100;
    	long Rate=10000;
    	WORD ADData[1000];
    	unsigned Options=CONVERTDATA;
    	float RevLevel=(float)CURRENTREVNUM;
    
    	ULStat=cbDeclareRevision(&RevLevel);
    	cbErrHandling(PRINTALL,DONTSTOP);
    	ofstream outdata;
    	outdata.open("realtime.csv");
    	outdata<<"Data Number,Voltage"<<endl;
    	printf("Beginning Real-Time Data Acquisition...");
    	system("LiveGraph.jar realtime.csv");
    	for(J=0;J<100;J++)
    	{
    		for (I=0;I<100;I++)
    		{
    			ULStat=cbAInScan(BoardNum,LowChan,HighChan,Count,&Rate,Gain,ADData,Options);
    			outdata<<""<<L<<","<<ADData[I]<<endl;
    			cout<<""<<ADData[I]<<endl;
    			L=L+1;
    			if(_kbhit())
    			{
    				I=100;
    				J=100;
    			}
    		}
    		I=0;
    	}
    	outdata.close();
    	_getch();
    }

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    I believe the function you are looking for is CreateProcess().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to stop a program from accessing the file system
    By gogoc in forum C++ Programming
    Replies: 8
    Last Post: 05-19-2008, 06:09 PM
  2. Closing an External Program
    By magic.mike in forum Windows Programming
    Replies: 3
    Last Post: 08-04-2005, 01:27 AM
  3. Replies: 1
    Last Post: 07-08-2005, 07:44 AM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. Replies: 2
    Last Post: 05-10-2002, 04:16 PM