Create Plugin to import file
Posted: Wed Feb 20, 2008 3:22 pm
hello DAVID,
I 'm actually working on a plugin that import a data file with several channels .
The format of the file is like this :
Number of sample of channel 1
x1 y1
x2 y2
x3 y3
....
Number of sample of channel 2
x1 y1
x2 y2
x3 y3
....
Number of sample of channel 3
x1 y1
x2 y2
x3 y3
....
for example
3
0.5 1.002
1.0 1.005
1.5 1.007
3
0.5 2.001
1.0 2.005
1.5 2.011
I'm using the following code, but the graph display only one curve, when I display or edit the array of the curve the arrays are empty except for the first one.
The code is th efollowing :
if (NULL == (f = fopen (Filename, "r"))) goto PluginExit;
i = 0;
while(fgets(szLine,sizeof(szLine),f))
{
sscanf(szLine,"%d",&m_NbSample);
if(i < (int)DPlot->MaxPoints)
{
for( a=0; a<m_NbSample; a++)
{
fgets(szLine,sizeof(szLine),f);
sscanf(szLine,"%lf%lf",&x,&y);
X = (float)x;
Y = (float)y;
i++;
}
N = DPlot->NumCurves;
DPlot->NP[N] = m_NbSample;
DPlot->NumCurves++;
lstrcpy(DPlot->Legend[N+1],"From SIMPLEFILE.DLL");
if(DPlot->NP[N] > DPlot->MaxPoints)
{
DPlot->MaxPoints = DPlot->NP[N];
RetCode = PLUGIN_BADARRAYSIZE;
goto PluginExit;
}
}
}
fclose(f);
Can you help me.
Thank you in advance
Regards
Franck
I 'm actually working on a plugin that import a data file with several channels .
The format of the file is like this :
Number of sample of channel 1
x1 y1
x2 y2
x3 y3
....
Number of sample of channel 2
x1 y1
x2 y2
x3 y3
....
Number of sample of channel 3
x1 y1
x2 y2
x3 y3
....
for example
3
0.5 1.002
1.0 1.005
1.5 1.007
3
0.5 2.001
1.0 2.005
1.5 2.011
I'm using the following code, but the graph display only one curve, when I display or edit the array of the curve the arrays are empty except for the first one.
The code is th efollowing :
if (NULL == (f = fopen (Filename, "r"))) goto PluginExit;
i = 0;
while(fgets(szLine,sizeof(szLine),f))
{
sscanf(szLine,"%d",&m_NbSample);
if(i < (int)DPlot->MaxPoints)
{
for( a=0; a<m_NbSample; a++)
{
fgets(szLine,sizeof(szLine),f);
sscanf(szLine,"%lf%lf",&x,&y);
X = (float)x;
Y = (float)y;
i++;
}
N = DPlot->NumCurves;
DPlot->NP[N] = m_NbSample;
DPlot->NumCurves++;
lstrcpy(DPlot->Legend[N+1],"From SIMPLEFILE.DLL");
if(DPlot->NP[N] > DPlot->MaxPoints)
{
DPlot->MaxPoints = DPlot->NP[N];
RetCode = PLUGIN_BADARRAYSIZE;
goto PluginExit;
}
}
}
fclose(f);
Can you help me.
Thank you in advance
Regards
Franck