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
 Calling X-function impNetCDF with OriginC
 New Topic  Reply to Topic
 Printer Friendly
Author  Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Doltergost

Germany
15 Posts

Posted - 11/27/2025 :  08:39:00 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

i tried to automate the import of netCDF file via OriginC. Similar to outher implimentation i tried to use the corresponding X-function.

void dc_NetCDF(importstruct *importdata, int index)
{
MyWorksheetPage wp;
wp.Create("origin");

// Load the X-Function
string strXFNameToCall = "impNetCDF";
XFBase xf(strXFNameToCall);
if( !xf.IsValid() )
{
printf("Failed to load xfunction.\n");
return;
}

Worksheet wks = wp.Layers(0);

string strURL = importdata->directory + importdata->filenames[index];
string wksname = "[Book1]Sheet1";
Tree tr;

if( !xf.SetArg("fname", strURL) )
{
printf("Failed to set argument fname\n");
return;
}

if( !xf.SetArg("orng", wksname) )
{
printf("Failed to set argument orng\n");
return;
}

// With arguments set we can now execute the X-Function
if( !xf.Evaluate() )
{
printf("Failed to evaluate the impNetCDF X-Function.\n");
return;
}

printf("%s importiert\n",importdata->filenames[index]);

string stemp = importdata->filenames[index];
stemp.Replace(importdata->voidstring, "");
importdata->longnames = stemp;

wks.SetName(importdata->longnames[index]);
wp.SetLongName(importdata->longnames[index]);
wp.SetName("A" + simple_hash(importdata->filenames[index], 10));

importdata->shortnames[index] = wp.GetName();
}

My Problem is now that it doesnt work. If i dont set the orng argument, i get the error <active> is not Valid, if i set it like above, i get errorcode (24). Can someone help?

Thanks in advance.
   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