Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
peroma
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
1 L A T E S T R E P L I E S (Newest First)
Mike Buess
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.