X-Functions for handling a variety of tasks. X-Functions can be called from both LabTalk and Origin C. This Section will show you how to call X-Functions from Origin C by using Origin C's XFBase class . This mechanism also can be used in calling one X-Function in another X-Function.
Origin has many built-inThe XFBase class is declared in the XFBase.h header file located in the Origin C System folder. The XFBase.h header file is not included in the Origin.h header file so it has to be included separately in any Origin C file for the use of XFBase class.
#include <XFBase.h>
The procedure to use X-Functions in Origin C is as following:
The following Origin C code defines a general function for importing files into Origin. The function has two arguments: data file name and import filter file name. Additional arguments of the impFile X-Function will use their default values.
bool call_impFile_XF(LPCSTR lpcszDataFile, LPCSTR lpcszFilterFile) { string strDataFile = lpcszDataFile; string strFilterFile = lpcszFilterFile; // Create an instance of XFBase using the X-Function name. XFBase xf("impFile"); if (!xf) return false; // Set the 'fname' argument. if (!xf.SetArg("fname", strDataFile)) return false; // Set the 'filtername' argument. if (!xf.SetArg("filtername", strFilterFile)) return false; // Call XFBase's 'Evaluate' method to execute the X-Function if (!xf.Evaluate()) return false; return true; }
The following Origin C code shows how to call the call_impFile_XF function defined above and use it to import an image file.
// Import the Car bitmap located in Origin's Samples folder. string strImageFile = GetAppPath(TRUE) + "Samples\\Image Processing and Analysis\\Car.bmp"; // Import the bitmap using the Image import filter. string strFilterFile = GetAppPath(TRUE) + "Filters\\Image.oif"; // Call the function that will use the impFile X-Function. call_impFile_XF(strImageFile, strFilterFile);
Note:
|