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
 Origin Forum
 problem with "while loop simulation"

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
mlhomer1 Posted - 01/07/2002 : 2:49:41 PM
I am very new to origin and labtalk. I am trying to read in some data files and search for a particular line. I have tried several ways to use the "while loop simulation", and every way seems to end up in an infinite loop. It's as if the program executes everything within the brackets of the for statement, without actually going back and evaluating expression2. All I want to do is stop at a line when the letter "h" is no longer found. Here is what I wrote:
for (ii=1; "%a" == "h"; ii++) { %a=%(jul1201la,1,ii); %a=;};
Alternately, I tried:
for (;"%a" != "n"; ) { %a= %(jul1201la,1,ii); ii++; };
Both end up in infinte loops. What am I doing wrong?
Thank you,
Margie
3   L A T E S T    R E P L I E S    (Newest First)
CStorey Posted - 01/10/2002 : 1:03:36 PM
The expression in the for loop is evaluated each time the loop is executed. The for loop will only evaluate an numerical expression, whereas a true WHILE loop may evaluate any condition. Thus in order to simulate a WHILE loop with a non-numerical end condition you need a combination or for and if expressions.

Hope this helps.
Craig

Craig Storey
Origin WebRing Member - http://g.webring.com/hub?ring=originwebring
mlhomer1 Posted - 01/07/2002 : 7:51:47 PM
Mike, thank you, that worked.

I have a question, though. In the manual, it gives an example of what they call a "while loop simulation". It seems to imply that that within the for brackets, the script will be executed until the value of expression 2 changes. Their example works, but I couldn't get it to work any other way. Is there some trick to knowing when the expression is evaluated?
Mike Buess Posted - 01/07/2002 : 4:31:18 PM
You need to put the break condition inside the brackets, not the parenthesis. The following script will test each cell in the first column of the active worksheet for the string 'h'. Note that it will stop on any string that is not identically 'h'. (It will stop on 'hh', 'gh', 'hi', etc.) It's more complicated if you're only looking for an arbitrary string that lacks the character 'h'.

for(ii=1;ii>0;ii++) {
%A=%(%H,1,ii); %A=;
if(%A!="h") break;
};

I hope that helps.

Mike Buess
Origin WebRing Member

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