Hi,
Although ASCIMP (which has been around since many versions) and Import Wizard Filter (introduced in 7.5) have many things in common and share internal code, from user point of view, one has to use one or the other and not possible to combine both.
So in your case you already have an import filter created with Import Wizard that has other things taken care of such as running script at end of import to do some tasks etc.
So you may want to work with the filter file alone and not the ASCIMP structure as saved in the worskheet.
You can use code such as below which reads the import filter .OIF file and then changes properties and then calls other Origin C functions to import the file.
The function ImportFile() has multiple prototypes which are declared in FileImport.h and so this header file needs to be added to your OC function code. In addition to that files such as FileImport.c and some other files related to Import Wizard need to be part of your workspace before you can compile and run the code below.
The easiest way to ensure that your workspace is set up for compiling the following code is:
1> Run the import wizard once from the GUI which loads and compiles all necessary files. Then as long as you do not change your workspace the necessary files will be there
OR
2> At the beginning of an Origin session (programmatically) use the run.loadoc() script command to load and compile the import wizard workspace, with command such as: (your path could be different)
run.loadoc("C:\Program Files\OriginLab\OriginPro75SR5\OriginC\OriginLab\ImportWiz.ocw");
Once you have done the above, you can then create a file with the code pasted bwlow and compile and link and call the function.
Easwar
OriginLab
#include <Origin.h>
// The following include file has protype of ImportFile() function
#include <..\OriginLab\FileImport.h>
void custom_import()
{
// Point to data file and to filer XML file
string strFile = "c:\\temp\\myfile.dat";
string strFilter = "c:\\temp\\myfilter.oif";
// Load filter file into a tree and examine current values
Tree trFilter;
trFilter.Load(strFilter);
printf("Num Header Lines: %d\n", trFilter.ASCIMP.iHeaderLines.nVal);
printf("Num SubHeader Lines: %d\n", trFilter.ASCIMP.iSubHeaderLines.nVal);
// or dump entire tree to script window
out_tree(trFilter);
// Change current values in tree
// Note: call your custom function here that examines file to determine
// number of header lines etc
trFilter.ASCIMP.iHeaderLines.nVal = 20;
trFilter.ASCIMP.iSubHeaderLines.nVal = 0;
// Create a new worksheet page (or point to one that exsits)
WorksheetPage wpg;
// Call import function passing tree for filter, and string for filename
int iret = ImportFile(wpg, trFilter, strFile, 0);
if( iret != 0 )
printf("Import call returned error: %d\n", iret);
}