This function is used to load filter from file to tree.
int load_import_filter(LPCSTR lpcszFilterName, LPCSTR lpcszDataFile, LPCSTR lpcszPageName, int nLocation, TreeNode& trFilter)
0 = success, -1 = failed, -2 = find function error.
Before compile this example please run run.LoadOC(Originlab\FileImport.c, 16); in Command Window to load all depentence source files.
#include <..\Originlab\FileImport.h> void load_import_filter_ex() { Page pg = Project.Pages(); // Active Page // Get page book name string strPageName = pg.GetName(); // Get Origin sample folder string strPath = GetAppPath(TRUE) + "Samples\\Import and Export\\"; // List all file names need to imported StringArray saFileNames; saFileNames.Add(strPath + "pCLAMP\\93310C08.DAT"); saFileNames.Add(strPath + "pCLAMP\\93310C10.DAT"); saFileNames.Add(strPath + "pCLAMP\\93311C01.DAT"); // specify .oif filter name, location see the setting of nLocation below. string strFilterName = "pCLAMP"; // import filter tree // about filter settings, refer to imppClamp xfunction tree variable "options" Tree trFilter; int nLocation = 1; // Origin exe folder, more options see the document of load_import_filter function. int nRet; nRet = load_import_filter(strFilterName, saFileNames[0], strPageName, nLocation, trFilter); if ( 0 == nRet ) out_str("Success to load import filter!"); else out_str("Failed to load import filter!\nPlease check strFilterName and nLocation if assigned correctly"); }
import_files
FileImport.h