Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
markus2k
Posted - 05/05/2004 : 09:02:12 AM Hello NG,
I want use Origin C in order to get an automatization for integrating about 30 Current/Time Curve at once. The problem is that the code I write brings origin to loading the tek0000n.csv files, integrates but it doesnt't take the data files from the folder, I've placed them before C:\O7\*.* ! I don't know the sources orgin c is using, but in fact it does something. This means I get an worksheet (wksArea) with #"Anzahl" entries . The code is compiled with intrenals.c and is in the Folder C:\O7\, the project name is import.opj. I'm using Origin 7.0 Further Questions: How can I write the Integration data from my worksheet wksArea directly into an ASCII file and close the worksheets. I tried LT_execute command, but just an empty file was created.
#include <origin.h>
void Automation(int Anzahl) {
// Declare root folder of PE for the current project Folder fldRootFolder = Project.RootFolder;
// Get file path of current project string strProjectPath; strProjectPath = Project.GetPath();
// Create a worksheet using custom template for Area //Worksheet wksArea; Worksheet wksArea; string strWksTemplate = strProjectPath + "csv2ascii.otw"; int nOptionW = CREATE_VISIBLE_SAME; bool bRetA = wksArea.Create(strWksTemplate,nOptionW);
// Declare datasets in worksheet to copy data from file Dataset dtX(wksArea,0); Dataset dtY(wksArea,1);
// Declare a curve object using x,y columns of worksheet Curve crvArea(wksArea, 0, 1);
// Get name of curve string strYAreaName; crvArea.GetName(strYAreaName);
Curve cc(dsX, dsY); IntegrationResult result; Curve_integrate(&cc, &result); double a; double b; int c; a = result.Area; b = result.xPeak; c = result.iPeak; //printf("The area is %.1f\n", result.Area); //printf("The peak position is %d\n", result.iPeak);
// Eintrag an leerer Zelle in Spalte 2 fortsetzen fldRootFolder.MakeActive(); for(int findex = 0; findex < Anzahl; findex++){ string findit; wksArea.GetCell(findex, 1, findit); string leer = "--"; int res = lstrcmp(leer,findit); if(res == 0) {dtY[findex]=a;dtX[findex]=b;break;} } ffDataFile.Close();
// Set PE folder path back to root fodler, for processing next file if any fldRootFolder.MakeActive();
} printf("done!\n");
} // end
1 L A T E S T R E P L I E S (Newest First)
Mike Buess
Posted - 05/05/2004 : 10:48:20 AM A couple of quick comments about your code...
1. I can't find where you've added the path to strFileName. ...It looks like you've placed the data files in your Origin program folder. OriginC's stdiofile does not automatically look there so ffDataFile should be declared as shown in #2.
2. You are mixing up the stdiofile and file classes. ffDataFile should be declared like this
stdioFile ffDataFile(GetAppPath()+strFileName, file::modeRead); // assuming datafiles are in Origin's program folder
Neither ffDataFile.Open(...) or ffDataFile.Close() belong in your code.
As for exporting the worksheet to file... I have used LT_execute("save -w wksName \"file path\\name\"") successfully in Origin 7.0. (It's usually safer to quote file path\name.)