Hi All,
I am trying to import and process multiple sets of data at the same time. My goal is to import all of them in different worksheets (to keep things neat later on), with each worksheet attached to a layer of a worksheet page. In this way, each dataset should appear in a different "tab" of the worksheet.
My problem is that the number of files I have to import changes everytime. Therefore, my guess is that I need to create a dynamic array of Worksheets, which I then attach to different layers. Somehow, I haven't found a way of doing it that actually works. My code so far is:
void testmain(){
//get input files
StringArray inputFiles;
string importfile;
int numFiles = GetMultiOpenBox(inputFiles,"[Curve Data (*.TXT)] *.TXT", "C:\Users\Desco\SFU\Thesis\Lumerical\Sims\Curves");
//open a new project
Project MyProj;
MyProj.Open();
//Create a new worksheet page
WorksheetPage wkspage();
wkspage.Create();
wkspage.Rename("Raw Data",FALSE,TRUE);
wkspage.Layers(0).Delete();
Worksheet wks;
ASCIMP ai;
//For every input file, create a new worksheet layer, and the associate worksheet handler
string name;
for (int i=0; i<numFiles; i++){
name=GetFileName(inputFiles[i],TRUE);
name.Delete(11,5);
int index = wkspage.AddLayer(name,CREATE_NO_DEFAULT_TEMPLATE );
wks=wkspage.Layers(index);
//add columns and get indexes
int lambdaIdx=wks.AddCol("Wavelength");
int transIdx = wks.AddCol("Transmission");
if (0 == AscImpReadFileStruct(inputFiles[i],&ai)){
if(0 == wks.ImportASCII(inputFiles[i], ai))
out_str("Import data successful: "+inputFiles[i]);
}
//problem...the last worksheet is getting displayed on all three layers
}
}
As you can see from the comment, since I'm effectively "recycling" the worksheet wks, I end up with all layers showing the same data (specifically, that of the file which was imported last).
Can anybody suggest a better way of doing this?
Thanks a million, and Cheers!
Gianmarco