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
 Calling X-Function with recalculate
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

altertoby

4 Posts

Posted - 03/05/2010 :  08:17:32 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver.: OriginPro 8 SR 0
Operating System: Win7 64


Is there a way to specify the "recalculate" - option in OriginC when calling a xf?
In LabTalk something like interp1xy iy:=Col(2) method:=spline npts:=50 -r 1 works like a charm, but I can't find a method of doing this from OriginC.

I find two promising method-signatures in XFBase:
int ExecuteLabTalk(LPCSTR lpcszArgs, vector<string>* pvsVarValues, LPVOID lpRetData = NULL, int nRetDataXVT = XVT_INT, int* lpOCerr = NULL, DWORD dwCntrl = 0, int nRecalculate = AU_NONE);

and
BOOL Run(int nAutoUpdate, TreeNode& trGetN = NULL, LPVOID lpRetData = NULL, int nRetDataXVT = XVT_INT, int* lpOCerr = NULL, DWORD dwCntrl = 0);

But the first method only accept a LabTalk-string (and I want to use the SetArg-Method -> So is there a way to generate the string after setting up the XFBase-object properly?) and the second method just don't register the recalculation-option.
So how to do it?
Thanks

Iris_Bai

China
Posts

Posted - 03/08/2010 :  9:14:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

We did not support this in Origin C. I submitted a tracker item #15183 to implement this feature.

Thanks your report.

Iris
Go to Top of Page

folger

China
6 Posts

Posted - 03/12/2010 :  05:56:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
We support calling XF with recalculate from OC since 80SR0, you can try the OC sample code about calling XF integ1 :

#include <..\originlab\XFunctionEx.h>
void	testXFOp()
{
	Worksheet	wks;
	wks.Create();
	wks.SetSize(-1, 4);
	vectorbase&		vx = wks.Columns(0).GetDataObject();
	vectorbase&		vy = wks.Columns(1).GetDataObject();
	vx.Data(1, 32);
	vy.Data(1, 32);
	
	XFunction	xf;
	Tree		trXF;
	Tree		trGetN;
	if ( !xf.Load(&trXF, "integ1", 0, true, false, true, trGetN) )
		return;
	
	XYRange		xyIn;
	xyIn.Add(wks, 0, "X");
	xyIn.Add(wks, 1, "Y");
	xf.SetArg("iy", xyIn);
	
	XYRange		xyOut;
	xyOut.Add(wks, 2, "X");
	xyOut.Add(wks, 3, "Y");
	xf.SetArg("oy", xyOut);
	xf.Run(AU_AUTO, trGetN);
}


Originlab Corp.
There is always something
Go to Top of Page

altertoby

4 Posts

Posted - 03/27/2010 :  11:56:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks folger for your help.
But apparently the code you provided does not work.

There is now the symbol for auto-recalculation, but if I open the "change parameter"-dialog wrong data is shown. In your example eg. the y-data is set to the created x-column and so the recalculation does not work either.

Any idea?
Go to Top of Page

folger

China
6 Posts

Posted - 03/28/2010 :  8:39:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Tobias:

The previous code did not work because trGetN is not correctly obtained. I change a little to make it work now, please check below :

#include <..\originlab\XFunctionEx.h>
void	testXFOp()
{
	Worksheet	wks;
	wks.Create();
	wks.SetSize(-1, 4);
	vectorbase&		vx = wks.Columns(0).GetDataObject();
	vectorbase&		vy = wks.Columns(1).GetDataObject();
	vx.Data(1, 32);
	vy.Data(1, 32);
	
	XFunction	xf;
	Tree		trXF;
	if ( !xf.Load(&trXF, "integ1", 0, true, false, true) )
		return;
	
	XYRange		xyIn;
	xyIn.Add(wks, 0, "X");
	xyIn.Add(wks, 1, "Y");
	xf.SetArg("iy", xyIn);
	
	XYRange		xyOut;
	xyOut.Add(wks, 2, "X");
	xyOut.Add(wks, 3, "Y");
	xf.SetArg("oy", xyOut);
	
	Tree		tr;
	TreeNode	trGetN;
	if ( !xf.GetGUI(tr, trGetN) )
		return;
	
	xf.Run(AU_AUTO, trGetN);
}


Seems you are using 80SR0, after running this code then change parameter to open dialog, you will see the input data is still displayed incorrectly as "([Book2]Sheet1!A,[Book2]Sheet1!B,<active>)". This is a known bug and fixed in SR2. However, you can go on changing some options and it will work fine with this "wrong" input data.

We highly recommend you to upgrade to 80SR6, which includes many others improvements and fixes :

http://wiki.originlab.com/~originla/wiki/index.php?title=Release_Notes

Originlab Corp.
There is always something

Edited by - folger on 03/28/2010 9:56:02 PM
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