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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 get Output from X-Function

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
fs_alex Posted - 04/15/2010 : 05:29:20 AM
Origin Ver. and Service Release (Select Help-->About Origin): v8.1.88.89
Operating System: Windows XP

Dear Origin Team,

is there any way that i can fetch the output of a (user defined) X-Function from OriginC ? For example if i want to feed the output of one X-Function to the input of another X-Function.
1   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 04/20/2010 : 06:11:33 AM
Hi,

The following example illustrates how to fetch use the output of one X-Function from Origin C, and then feed the output to the input of another X-Function.

#include <XFbase.h>
void output_as_input()
{
	Worksheet wks = Project.ActiveLayer();
	if(!wks)
		return;
	
	Column col = wks.Columns(0);  // first column in worksheet
	
	// X-Function: spline
	string strXF1 = "spline";
	XFBase xf1(strXF1);
	
	vector vData(col);
	xf1.SetArg("ix", vData);  // set input: ix
	
	vector vOutput;
	vOutput.SetSize(vData.GetSize());
	xf1.SetArg("ox", vOutput);  // set output: ox
	
	DataRange dr;
	dr.Add("X", wks, 0, 1, -1, 1);  // second column in worksheet
	dr.Add("Y", wks, 0, 2, -1, 2);  // third column in worksheet
	xf1.SetArg("iy", dr);  // set argument iy
	
	// execute X-Function spline
	xf1.Evaluate();	
	
	// X-Function: stats
	string strXF2 = "stats";
	XFBase xf2(strXF2);
	
	// set input: ix, with the output of X-Function spline
	xf2.SetArg("ix", vOutput);
	
	// output of X-Function stats
	double dMean;
	double dMin;
	double dMax;
	double dSum;
	xf2.SetArg("mean", dMean);
	xf2.SetArg("min", dMin);
	xf2.SetArg("max", dMax);
	xf2.SetArg("sum", dSum);
	
	// execute X-Function stats
	xf2.Evaluate();
	
	// print result of X-Function stats
	printf("Statistics Results:\nMean=%f\nMin=%f\nMax=%f\nSum=%f\n", dMean, dMin, dMax, dSum);
}

Please note that, those X-Function, whose input and output data type is related to the worksheet, for example, Range, DataRange, etc., can not be used in such case. In the code above, the data type of output in X-Function spline is vector, and the data type of input in stats owns the same one with spline.

Penn
OriginLab Technical Services

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000