This function is called from the OC code and is for user import file with the specified filter.
int import_file(LPCSTR strPageName, int nIndexLayer, LPCSTR lpcszDataFile, LPCSTR lpcszFilterName = NULL)
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> // import file with filter to active layer void import_file_with_specify_filter_ex1() { Page pg = Project.Pages(); // Active Page // Get page book name string strPageName = pg.GetName(); // Get page active layer index int nIndexLayer = pg.Layers().GetIndex(); // Get Origin sample folder string strPath = GetAppPath(TRUE) + "Samples\\Signal Processing\\"; // specify .oif filter name string strFilterName = "TR Data Files"; int nRet = import_file(strPageName, nIndexLayer, strPath + "TR2MM.dat", strFilterName); if ( 0 == nRet ) out_str("Success to import!"); else out_str("Failed to import!"); }
FileImport.h