| Author |
Topic  |
|
|
peroma
Germany
26 Posts |
Posted - 01/14/2004 : 12:36:48 PM
|
Hi forum,
I have made a script, that it supposed to import all files of a directory with a certain name. The names of the files are: *number.dat where "number" is running from 01 to 22.
(01, 02, ..., 09, 10, ...)
create a number of files that are consistant with this rule and try the following script:
getfile *.dat; %A = %[%A,%[%A]-7]; %n = 01; %L = %B%A%N.dps;
for (n=2; file.exist(%L); n++) { %L=; if !(file.exist(%L)) break; if (n<10) %n = 0$(n); else %n = $(n); %L = %B%A%N.dat; };
When I tried this, the script stopped after typing the 1. non existing file-name. So the "if stament" registered that this file does not exist while the "for statement" didn't. Is that a bug of Origin 7.0G?
Thank's for any help!
Peter |
|
|
Mike Buess
USA
3037 Posts |
Posted - 01/14/2004 : 2:32:32 PM
|
Hi Peter,
Try using an explicit condition in the for statement...
for(n=2; file.exist(%L)>0; n++)
...That's not right. I was testing with exist(%L) by mistake. In any case, the standard LabTalk method for simulating a while loop is something like this
for (n=2; n>0; n++) { %L=; if (!file.exist(%L)) break; if (n<10) %n = 0$(n); else %n = $(n); %L = %B%A%N.dat; };
In other words the 'for' condition is on the variable that's being looped.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 01/14/2004 3:43:44 PM |
 |
|
| |
Topic  |
|
|
|