Author |
Topic |
|
diemutigenmungos
5 Posts |
Posted - 01/08/2012 : 2:08:03 PM
|
Origin Ver. 7.5 Operating System: Win7 64bit
Hi! I am working on a OriginC Program (c++) to handle my Measurements. I started small and kept on building up my program. One of the first tasks is to copy whole columns out of my imported data into single workbooks. Everything worked fine and I added another Import-function to get more columns. My code worked for the other columns and I used exactly the same but unfortunately, I get a quote: #command error
in origin itself and a quote: Origin C Function Runtime Error, unknown error
in the code builder. Compiling went fine without any errors and when I put the newly added part in comments, everything works as before. Here is a part of the Code: quote: void CVFunction(WorksheetPage page,Worksheet outSheetCVFor,Worksheet outSheetCVBack, Worksheet outSheetCVDit,string chip){ foreach(Layer lay in page.Layers){ //prepare out //get the colums Worksheet wks = lay; Dataset ds(wks, 1); foreach(Column cc in wks.Columns) { vector<double> vec = cc.GetDataObject(); //check the column type if (cc.GetLongName()=="V_m_for"){ int index = outSheetCVFor.AddCol(chip+"o"); Column newCol = outSheetCVFor.Columns(index); newCol.SetComments(cc.GetComments()); newCol.SetLongName("U"); newCol.SetUnits("V"); newCol.SetType(3); ds.Attach(outSheetCVFor,index); ds = vec; } if (cc.GetLongName()=="C_m_for[pF]"){ int index = outSheetCVFor.AddCol(chip+"o"); Column newCol = outSheetCVFor.Columns(index); newCol.SetComments(cc.GetComments()); newCol.SetLongName("C bei 1MHz"); newCol.SetUnits("pF"); newCol.SetType(0); ds.Attach(outSheetCVFor,index); ds = vec; } if (cc.GetLongName()=="V_m_back"){ int index = outSheetCVBack.AddCol(chip+"o"); Column newCol = outSheetCVBack.Columns(index); newCol.SetComments(cc.GetComments()); newCol.SetLongName("U"); newCol.SetUnits("V"); newCol.SetType(3); ds.Attach(outSheetCVBack,index); ds = vec; } if (cc.GetLongName()=="C_m_back[pF]"){ int index = outSheetCVBack.AddCol(chip+"o"); Column newCol = outSheetCVBack.Columns(index); newCol.SetComments(cc.GetComments()); newCol.SetLongName("C bei 1MHz"); newCol.SetUnits("pF"); newCol.SetType(0); ds.Attach(outSheetCVBack,index); ds = vec; } if (cc.GetName()=="C23"){ int index = outSheetCVDit.AddCol(chip+"o"); Column newCol = outSheetCVDit.Columns(index); newCol.SetComments(cc.GetComments()); newCol.SetLongName("E-E\-(FI)"); newCol.SetUnits("eV"); newCol.SetType(3); ds.Attach(outSheetCVDit,index); ds = vec; } if (cc.GetName()=="C24"){ int index = outSheetCVDit.AddCol(chip+"o"); Column newCol = outSheetCVDit.Columns(index); newCol.SetComments(cc.GetComments()); newCol.SetLongName("D\-(it)"); newCol.SetUnits("cm\+(-2)ev\+(-1)"); newCol.SetType(0); ds.Attach(outSheetCVDit,index); ds = vec; } } } }
this is the Function code for copying the columns. The last 2 if-Commands are the one who cause the problem. I call the function with quote: CVFunction(page,outSheetCVFor,outSheetCVBack,outSheetCVDit,chip.GetName());
Everything in the program works well, except these 2 if-Commands.
I excuse myself in advance for my bad programming style, but I'm really new to this materia.
I somebody could help me find the problem, or help me to change the code, I would be really happy!
Thanks for everything,
Momo
|
|
orglbas
1 Posts |
Posted - 01/08/2012 : 8:49:47 PM
|
thanks,very much.
http://www.wowat.de |
Edited by - orglbas on 01/08/2012 8:51:03 PM |
|
|
Penn
China
644 Posts |
Posted - 01/08/2012 : 9:09:56 PM
|
Hi Momo,
From the information you provided in the post, you are using Origin 7.5, right? As I know, there is no GetLongName method defined for Column class yet. Also, the GetName method is not used like this in Origin 7.5. You can see the prototype of this method below:
PUBLIC int GetName(string &strName)
So, I am afraid that you cannot call this method as your code did.
By the way, when I compile your code, error happens for GetLongName method. So, I am not sure why you can compile it successfully.
Penn |
|
|
diemutigenmungos
5 Posts |
Posted - 01/09/2012 : 04:40:13 AM
|
Hi! Thanks for your fast replies. I isolated the Failure-Causing Code Fragment by inserting several print-commands. The failure happens here: quote: if (cc.GetName()=="C23"){ int index = outSheetCVDit.AddCol(chip+"o"); Column newCol = outSheetCVDit.Columns(index); newCol.SetComments(cc.GetComments()); newCol.SetLongName("E-E\-(FI)"); newCol.SetUnits("eV"); newCol.SetType(3); ds.Attach(outSheetCVDit,index); ds = vec;
} if (cc.GetName()=="C24"){ int index = outSheetCVDit.AddCol(chip+"o"); Column newCol = outSheetCVDit.Columns(index); newCol.SetComments(cc.GetComments()); newCol.SetLongName("D\-(it)"); newCol.SetUnits("cm\+(-2)ev\+(-1)"); newCol.SetType(0); ds.Attach(outSheetCVDit,index); ds = vec; }
I also tried to split it up like this: quote: Column newCol; newcol = outSheetCVDit.Columns(index);
In that case, he generates the Column-Variable but stops after I link it to the newly created column. The GetName and GetLong name functions both work fine, I tried it by printing the value.
I really don't have any idea how to fix it. Any further suggestion?
Thanks again in advance!
Momo |
|
|
Penn
China
644 Posts |
Posted - 01/09/2012 : 9:34:39 PM
|
Hi Momo,
Obviously, you are not using Origin 7.5. When runtime error happens, the most case is that an invalid object is using in the code, such as invalid Worksheet object, invalid Column object, etc. So, you can consider whether the object is valid before using it. For example:
if( outSheetCVDit.IsValid() )
{
int index = outSheetCVFor.AddCol(chip+"o");
Column newCol = outSheetCVDit.Columns(index);
if( newCol.IsValid() )
{
...
}
}
So, you can have a try that.
Penn |
|
|
diemutigenmungos
5 Posts |
Posted - 01/10/2012 : 04:52:28 AM
|
Thanks Penn! Obviously the Worksheetpage isn't valid! Any Suggestions for that? I created 3 others with exactly the same code and they all are working without any problems. This is how I create the Worksheetpage:
quote: WorksheetPage nepCVDit; if(nepCVDit){ out_str("nepCVDit is valid"); } nepCVBack.Create("ORIGIN"); nepCVBack.SetName("Dit "+subfolder.GetName()); Worksheet outSheetCVDit = nepCVDit.Layers(0); if(outSheetCVDit){ out_str("outSheetCVDit is valid"); }
Funnyly, the newly created Worksheetpage called "Dit + subfoldername" is created in Origin itself...
PS: I checked the Version: It's 8.5.1 |
Edited by - diemutigenmungos on 01/10/2012 04:54:08 AM |
|
|
Penn
China
644 Posts |
Posted - 01/10/2012 : 05:17:39 AM
|
Hi Momo,
This time the code you provided is different from the one in the first your post. With just this code snippet, I cannot tell what the problem is. For example, in the code you provided this time, firstly, you have declared a WorksheetPage (nepCVDit), and then have nothing to do with it. Of course, this WorksheetPage is not valid. And then the nepCVBack comes out, is this another WorksheetPage?
It is better that you can provide complete steps for reproducing your problem. If not, I cannot tell what the actual problem is. Thanks.
Penn |
|
|
diemutigenmungos
5 Posts |
Posted - 01/10/2012 : 06:40:58 AM
|
void callAll() {
Folder fldroot("/Versuchsnummer/");
foreach (Folder subfolder in fldroot.Subfolders){
//create output worksheet
subfolder.Activate();
WorksheetPage nepCVFor;
nepCVFor.Create("ORIGIN");
nepCVFor.SetName("C-V for "+subfolder.GetName());
Worksheet outSheetCVFor = nepCVFor.Layers(0);
WorksheetPage nepCVBack;
nepCVBack.Create("ORIGIN");
nepCVBack.SetName("C-V back "+subfolder.GetName());
Worksheet outSheetCVBack = nepCVBack.Layers(0);
WorksheetPage nepCVDit;
if(nepCVDit){
out_str("nepCVDit is valid");
}
nepCVBack.Create("ORIGIN");
nepCVBack.SetName("Dit "+subfolder.GetName());
Worksheet outSheetCVDit = nepCVDit.Layers(0);
if(outSheetCVDit){
out_str("outSheetCVDit is valid");
}
//loop throug the input
foreach (Folder chip in subfolder.Subfolders){
foreach(Folder blarz in chip.Subfolders){
if (blarz.GetName() == "C-V") {
foreach (PageBase page in blarz.Pages) {
if (page.GetType() == EXIST_WKS ) {
WorksheetPage gnarz(page);
CVFunction(page,outSheetCVFor,outSheetCVBack,outSheetCVDit,chip.GetName());
}
}
}
}
}
}
}
this is the main method which is calling the function "CVFunction" I shortened the code to the parts of interest. Everything worked fine for outSheetCVBack and outSheetCVFor, thats why I don't get the problem!
|
|
|
Penn
China
644 Posts |
Posted - 01/10/2012 : 10:00:14 PM
|
Hi Momo,
I am afraid that I cannot reproduce your problem. Could you please send your project, together with your code, to technical support via this page. Please refer to this post in your email.
Penn |
|
|
diemutigenmungos
5 Posts |
Posted - 01/11/2012 : 05:08:41 AM
|
I am now working with Origin 8. My friend's computer had another version on it but the problem still exists here. I wrote to the technical support as you told me! |
|
|
|
Topic |
|
|
|