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
 LabTalk Forum
 funny "for"
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peroma

Germany
26 Posts

Posted - 01/14/2004 :  12:36:48 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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