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 multiple ASCII Files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Dr.Klein

Germany
Posts

Posted - 03/09/2004 :  12:03:58 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,
my first OriginC function looks like this:

void ReadASCII()
{
ASCIMP ascimp;
string strFile = "C:\\tmp\\Image2_1.txt";

if(AscImpReadFileStruct(strFile,&ascimp)!=0)
{
out_str("cannot read ascii file");
return;

}
Worksheet wks;
wks.Create();
wks.ImportASCII(strFile, ascimp);
}

It imports the ASCII file "Image2_1.txt" into a worksheet. But I have many files in that folder, all named Image2_2, Image2_3,... and so on.

I would like to import them all into different worksheets. How do I loop through the folder c:\tmp ?

Thanks,

Oliver

Mike Buess

USA
3037 Posts

Posted - 03/09/2004 :  12:32:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver,

This will apply your function to all TXT files in C:\tmp...
void ImportFolder()
{
string strPath = "C:\\tmp\\";
StringArray saFiles;
FindFiles(saFiles,strPath,"txt");
for(int i=0;i<saFiles.GetSize();i++)
ReadASCII(strPath + saFiles[i]);
}


void ReadASCII(string strFile)
{
ASCIMP ascimp;
if(AscImpReadFileStruct(strFile,&ascimp)!=0)
{
out_str("cannot read " + strFile);
return;
}
Worksheet wks;
wks.Create();
wks.ImportASCII(strFile, ascimp);
}


Mike Buess
Origin WebRing Member
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