Re: FileNamesin a loop..
- To: mathgroup at smc.vnet.net
- Subject: [mg62096] Re: FileNamesin a loop..
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Fri, 11 Nov 2005 02:52:00 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 11/10/05 at 2:50 AM, uli.wuerfel at fmf.uni-freiburg.de (Uli Würfel) wrote: >I want to carry out the same calculation repeatedly, but with >different sets of parameters. The parameters are located in files >and I tried to use >dateien = FileNames["para*.txt"] >Then, I wanted to use a simple loop in the way: >For[i=1,i<=Length[dateien], >{ > str=OpenRead[dateien[[i]]]; > ---- Reading of parameters --- > Close[str]; > -----calculations--- >}; >i++] >Unfortunately, it does not work. Could you help? What you have outlined above should work. The fact that it doesn't work indicates the problem is with the parts of the code you didn't post. So without additional detail, it is impossible to identify the issue. However, it might be worth pointing out the For loop isn't needed. Instead you could structure things as follows: parameterReadFunction[filename_String]:= ... caluculationFunction[parameters...]:= ... calculationFuction[paramterReadFunction@#]&/@FileNames["para*.txt"] One of the advantages of structuring the code this way is it makes it easier to debug. -- To reply via email subtract one hundred and four