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
 funny "for"

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
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.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/14/2004 3:43:44 PM

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