The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 How to save a worksheet?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Koguma

Brazil
Posts

Posted - 04/05/2006 :  2:14:26 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Origin 7.0 SR0 v7.0220(B220)):
Operating System:Windows XP

Hi!
I am a Brazilian student and start to program Origin C Code Builder recently.Im my code, i subtract one worksheet for another one...and integrate after that.I do 2 diferents methods : subtract method and intehrate method.I have no problems in this part of code,the methods works separately , but for to group that 2 methods , i need to save a worksheet.
I know and read about LabTalk, but dont obtain sucess.
My code is below and forgive me my poor English.

#include <origin.h>
#include <mswin.h>
#include <data.h>
#include <Wksheet.h>
#include <stdio.h>
#include <Project.h>
#include <Page.h>

int i=0,j=0;
double aux1,aux2,aux3,resul;

void sub(){
Worksheet wks1();
BOOL bOK = wks1.Open("C:\Documents and Settings\CompLEVB\Meus documentos\Erick\Data1.ogw");

Worksheet wks2;
BOOL bOK2 = wks2.Open("C:\Documents and Settings\CompLEVB4\Meus documentos\Erick\Data2.ogw");

wks1.AddCol("Sub");
j=wks1.GetNumRows();

for(i=0;i<wks1.GetNumRows();i++)
{
//subtract(i do my own code) aux1=wks1.Cell(i,1);
aux2=wks2.Cell(i,1);
resul=aux1-aux2;
wks1.SetCell(i,2,resul);
}
}
void integra()
{
string nome1=InputBox("Entre com o nome do 1 worksheet:");
Worksheet wks1(nome1);
Curve cvMyCurve( "Data1_A", "Data1_Sub" ); Curve cvMyBaseline();
IntegrationResult irMyResults; wks1.AddCol("i");
Dataset dsCumIntRes( "Data1_i" ); dsCumIntRes.SetSize( cvMyCurve.GetSize() ); Curve_integrate( &cvMyCurve, &irMyResults, &cvMyBaseline, &dsCumIntRes, TRUE ); // Perform integration
}
This appears when i build my code :
compiling...
redfluo.c
Linking...
Done!
C:\Programas cientificos\OriginC\redfluo.c(35) :Origin C Function Runtime Error, general operation failure
C:\Programas cientificos\OriginC\redfluo.c(35) :Origin C Function Runtime Error, general operation failure
C:\Programas cientificos\OriginC\redfluo.c(22) :Origin C Function Runtime Error, general operation failure

Please help me
Thanks

Mike Buess

USA
3037 Posts

Posted - 04/06/2006 :  08:24:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The errors were not generated during the build but rather while running one of the functions. Your first function will generate a runtime error if the second worksheet file does not exist or has fewer rows than the first. You can find out yourself which line is generating the error by double-clicking the error message... CodeBuilder will move the cursor to the offending line.

Mike Buess
Origin WebRing Member
Go to Top of Page

Koguma

Brazil
Posts

Posted - 04/18/2006 :  4:04:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks i improved my code but i cant save the worksheet yet.
where this code goes?

#ifdef salvar
[Main]
-i Data1.ogw
#endif

and LT_execute????

Thanks for the patience!!!
the code is below !!!

#include <origin.h>
#include <mswin.h>
#include <data.h>
#include <Wksheet.h>
#include <stdio.h>
#include <graph.h>
#include <Project.h>
#include <Page.h>

void teste(){
//chama os worksheets
Worksheet wks1("Data1");
BOOL bOK = wks1.Open("C:\Documents and Settings\CompLevb5\Meus documentos\Erick\Data1.ogw");
Worksheet wks2("Data2");
BOOL bOK2 = wks2.Open("C:\Documents and Settings\CompLevb5\Meus documentos\Erick\Data2.ogw");
wks1.AddCol("Sub");
//subtrai
Dataset d1("Data1_B");
Dataset d2("Data2_B");
Dataset d3("Data1_Sub");
d3=d1-d2;
//integra
Curve cvMyCurve( "Data1_A", "Data1_Sub" ); // Create curve object to integrate
Curve cvMyBaseline();
IntegrationResult irMyResults; // OriginC structure to store integration results
wks1.AddCol("i");
Dataset dsCumIntRes( "Data1_i" ); // Cumulative integration result
dsCumIntRes.SetSize( cvMyCurve.GetSize() ); // Set size of dsCumIntRes to size of cvMyCurve
Curve_integrate( &cvMyCurve, &irMyResults, &cvMyBaseline, &dsCumIntRes, TRUE ); // Perform integration
dsCumIntRes=dsCumIntRes*-1;

}
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 04/18/2006 :  8:28:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
where this code goes? #ifdef salvar ... #endif
If I understand what you are trying to do then you don't need that at all. Just add this at the very end of your teste() function...

wks1.LT_execute("save -i C:\Documents and Settings\CompLevb5\Meus documentos\Erick\Data1.ogw");

Also, the only header file you need to #include is origin.h.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 04/18/2006 8:37:35 PM
Go to Top of Page

Koguma

Brazil
Posts

Posted - 04/25/2006 :  10:58:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot!!! Works perfectly!
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000