Repeat loop has trouble with imbedded While loop

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
obfusc88
Pro Scripter
Posts: 85
Joined: Wed Mar 14, 2007 6:22 pm

Repeat loop has trouble with imbedded While loop

Post by obfusc88 » Thu May 17, 2012 3:01 am

I have a long Repeat...Until loop that was failing. Kept getting a message on the Until line that the Repeat variable could not be found. It took some time to isolate the problem, but I have been able to make a model that duplicates the problem.

Code: Select all

Let>vSkip=False
Let>vTemp=XX
Let>k=0
Repeat>k
    Let>k=k+1
    Message>k = %k%
/*
//    While>vSkip=True
//        If>%vTemp%=*/
//            MessageModal>in While Loop
//            GoTo>Finish
//        EndIf
//        Message>While is over
          GoTo>Good 
//    EndWhile
*/
    Message>Next Until is a problem
Label>Good
Until>k>3
Label>Finish
MessageModal>DONE.  k = %k%
Normal code has none of the "comment" lines or block.
Running with normal lines produces error message.
So, I tried to comment out the While loop
If I put "//" in front of all the lines, the script failed.
If I add "/*" and "*/" around the "// lines, the script is OK
If I Single Step through the code, it jumps to // MessageModal>inWhileLoop vs. skipping commented lines.
If I Single Step using only /*....*/ and no // lines, it jumps to MessageModal and GOTO lines, skipping the Until completely.

So, a few questions:
1. Is there any reason I cannot use a While loop inside a Repeat..Until loop?
2. Why does the flow go to the commented line in the middle?
3. How to modify the syntax to allow the While inside the Repeat?
4. The actual While loop has many lines that get executed. The normal state of While looptests is False on both If commands, why does Single Step go through the lines when block is commented out?

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu May 17, 2012 3:55 am

"*/" is the end of block chars and the script doesn't like to see them just hanging around suspiciously out of place.

Instead of

Code: Select all

If>%vTemp%=*/
Try:

Code: Select all

If>%vTemp%={"*/"}

obfusc88
Pro Scripter
Posts: 85
Joined: Wed Mar 14, 2007 6:22 pm

Post by obfusc88 » Thu May 17, 2012 4:18 am

Thanks. For sure that's not in the manuals anywhere, that is only experience talking. Solved it for me. So it had nothing to do with imbedding a While loop, it had to do with a specific variable match. It's a good thing I used the actual While value vs. a sample one, but then that probably would not have failed!

Thanks again.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts