The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 import_file() and int nIndexLayer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Alexander N

Germany
18 Posts

Posted - 10/06/2009 :  06:51:05 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.0 SR6
Operating System:Win XP Pro

Hi guys,

I might have found a bug: If I add a new layer to the active worksheet and use then import_file with nIndexLayer = 1 or 2 for the just added new layer, I get an import error.

If I use nIndexLayer=0 I can import the data, but then my old sheet is overwritten. Here's a code snippet based on the help file:

bool importCVC(string strFile) {
	LT_execute("run.LoadOC(Originlab\FileImport.c, 16);");
	Page pg = Project.Pages(); // Active Page
	string strPageName = pg.GetName();
	pg.AddLayer("fit");
	pg = Project.Pages();

    // Get page active layer index
    int nIndexLayer = pg.Layers().GetIndex()+1;
    
    // specify .oif filter name
    string strFilterName = "Test";
 
    int nRet = import_file(strPageName, nIndexLayer, strFile, strFilterName);
 
 
    if ( 0 == nRet ) {
        out_str("Success to import!");
    	return true;
	} else {
        out_str("Failed to import!");
        return false;
	}
}

Iris_Bai

China
Posts

Posted - 10/08/2009 :  10:14:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

nIndexLayer is 0 offset. Please use the following code to get the index of newly added layer.

int nIndexLayer = pg.AddLayer("fit");

Iris
Go to Top of Page

Alexander N

Germany
18 Posts

Posted - 10/09/2009 :  07:33:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok, thanks a lot. This solution works better than mine.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000