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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 how to loop over subfolders and all xls inside?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
akuhr Posted - 03/06/2019 : 1:06:49 PM
OriginPro 2019, Win7Pro

Hello!

I want to give a path as parameter and then
let labtalk loop over all subfolder, in
every subfolder find all xls and doing
something with them.
The code I put here are only the booth mainloops
outside.
Inside the innerloop I do something with
imExcel and plotting. This is working.
First I have only the loop over the xls, which
was working and I now added the outer loop
looping over all subfolders.

But then it is not longer running, but
I dont find out, what is going wrong there?

How can I get it running?

string folder$;
string fname$;
string path$;
path$ = %1;

int number;
findfolders addpath:=1 n:=number;
for (int j=1; j<=number; j++)
{

   findFiles path:=folder.GetToken(j, CRLF)$ ext:="*.xls" addpath:=0;
   int nn = fname.GetNumTokens(CRLF);
   string fnnamesav$ = fname$;

   type "";
   #type "Pfad: $(path)";
   type "files found: $(nn)";
   type "";

   for (int i=1; i<=1; i++) // nn
   {
      string strFilename$ = fname.GetToken(i, CRLF)$;
      #type strfilename$;
   
      string name$ = strfilename$;

      int ibis = name.Len();
      int ibis = $(ibis) - 4;
      string fn$ = name.mid(1,$(ibis))$;

      type "opening $(i) with: %(fn$)";
      
      fname$ = fnnamesav$;

   }

}

Regards, Astrid
2   L A T E S T    R E P L I E S    (Newest First)
akuhr Posted - 03/07/2019 : 06:53:58 AM
Hello!

Thanx a lot.
It is working very well.

Regards, Astrid
yuki_wu Posted - 03/07/2019 : 02:44:49 AM
Hi Astrid,

You might forget to specify a string variable for the output string of folder when you call findFolders X-Function. Use like this:

int nFolders;
string strFolders;
findfolders path:="E:\MyFolder" addpath:=1 n:=nFolders folder:=strFolders;
for(int ii = 1; ii <=nFolders; ii++)
{
	strTemp$ = strFolders.GetToken(ii, CRLF)$;
	type -a strTemp$;
}


Hope it helps.

Regards,
Yuki

OriginLab

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000