2.1.13.14 import_file


Description

This function is called from the OC code and is for user import file with the specified filter.

Syntax

int import_file(LPCSTR strPageName, int nIndexLayer, LPCSTR lpcszDataFile, LPCSTR lpcszFilterName = NULL)

Parameters

strPageName
target book name.
nIndexLayer
index of sheet on book.
lpcszDataFile
full path of data file.
lpcszFilterName
full path of filter file or filename only.
If filename only, the path priority of filter file: Data Folder > Origin User Folder > Origin System Folder.
If NULL, will auto detect suitable filter, if find multiple suitable filter will popup a box to choose one.

Return

0 = success, -1 = failed, -2 = find function error.

Examples

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!");
}

Remark

See Also

Header to Include

FileImport.h

Reference