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
 Forum for Origin C
 mathtool syntax in Origin C
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

LC_

42 Posts

Posted - 06/04/2013 :  11:24:44 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.5.0 SR1
Operating System: Win 7

Hi
I'm implementing a call to the mathtool fnction in an Origin C routine, but currently I'm not getting the expected results. The routine below is part of a larger routine therefore I only pasted the relevant part below (all variables are OK upon inspection). I'm expecting the result of the curve math to be put into 1st and 2nd columns of WksOut via xy_O XYRange, but the option oy:=xy_O apparently has no effect if activated.

If I comment this line:

xfmath.SetArg("oy", xy_O); //should put results into xy_O, but doesn't

the math is performed and the result is put into a new worksheet, contrary to what the Help file suggests(according to the help, via script the default output should be <input>). If activated, xy_O is returned blank.

Also, if I don't specify properly what xy_O should be as in:

xy_O.SetData(&vx_O, &vy_O);

the x-function won't run with error (24). Therefore I would expect to get the results in the right columns, but all I get is an empty xy_O range in return. Where's the error?


Thanks in advance

ps: the help doesn't specify the syntax for the operator, operand and common options, but I think I got it by trial and error (see comments below).

Extract of code:

XYRange xy_B; //baseline range
XYRange xy_S; //data to be subtracted from baseline
XYRange xy_O; //output

Column cx_O(WksOut,0); //WksOut is an existing worksheet where the results should be put in
Column cy_O(WksOut,1); //columns 0 and 1 exist in WksOut

vector<double>& vx_O = cx_O.GetDataObject(); //vx_O
vector<double>& vy_O = cy_O.GetDataObject();

//defines input and output ranges
DataPlot dp_B = gl.DataPlots(0); //gl is the active graph layer, 1st curve is baseline
dp_B.GetDataRange(xy_B);
DataPlot dp_S = gl.DataPlots(1); //2nd curve contains data to be subtracted
dp_S.GetDataRange(xy_S);
xy_O.SetData(&vx_O, &vy_O);

//X-Function call
XFBase xfmath("mathtool");
xfmath.SetArg("iy1", xy_S);
xfmath.SetArg("operator", 1); //assuming 1 is code for subtract
xfmath.SetArg("operand",1); //assuming 1 is code for reference data
xfmath.SetArg("iy2", xy_B);
xfmath.SetArg("oy", xy_O); //should put results into xy_O, but doesn't
xfmath.SetArg("common",1); //assuming 1 is code for common range only
xfmath.Evaluate();

Penn

China
644 Posts

Posted - 06/06/2013 :  05:43:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

It works if I change to the following way.

XYRange xy_B;	//baseline range
XYRange xy_S;	//data to be subtracted from baseline
//XYRange xy_O;	//output

//Column cx_O(WksOut,0); //WksOut is an existing worksheet where the results should be put in
//Column cy_O(WksOut,1); //columns 0 and 1 exist in WksOut

//vector<double>& vx_O = cx_O.GetDataObject(); //vx_O 
//vector<double>& vy_O = cy_O.GetDataObject();
DataRange dr;
dr.Add(WksOut, 0, "X");
dr.Add(WksOut, 1, "Y");
XYRange xy_O(dr);

//defines input and output ranges	
DataPlot dp_B = gl.DataPlots(0); //gl is the active graph layer, 1st curve is baseline
dp_B.GetDataRange(xy_B);
DataPlot dp_S = gl.DataPlots(1); //2nd curve contains data to be subtracted
dp_S.GetDataRange(xy_S);
//xy_O.SetData(&vx_O, &vy_O);	

//X-Function call
XFBase xfmath("mathtool");	
xfmath.SetArg("iy1", xy_S);	
xfmath.SetArg("operator", 1); //assuming 1 is code for subtract
xfmath.SetArg("operand",1); //assuming 1 is code for reference data
xfmath.SetArg("iy2", xy_B);
xfmath.SetArg("oy", xy_O); //should put results into xy_O, but doesn't
xfmath.SetArg("common",1); //assuming 1 is code for common range only	
xfmath.Evaluate();


Penn
Go to Top of Page

LC_

42 Posts

Posted - 06/06/2013 :  08:16:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks very much, Penn! It works great now. I had tried this path, but was doing something wrong on the way.
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