Repeat Loop Question

Warren Kuhl warrenkuhl at gmail.com
Fri Dec 3 14:33:53 EST 2010


Bob,

Thanks for the clarification!  You are right about things getting ugly.  My
results were very inconsistent and took a look time trying to debug to
figure out what was causing the problem.

Warren

On Fri, Dec 3, 2010 at 1:30 PM, Bob Sneidar <bobs at twft.com> wrote:

> I believe the reason that works you the form you use did not, is because
> with repeat for, the max count is evaluated as a constant, so it takes
> whatever value you have in tCount and stores it in it's own internal max
> count. Changing tCount does NOT alter that.
>
> However with Repeat While, the conditions are evaluated upon each loop, so
> it works. You will find other issues with certain forms of repeat, like
> repeat for each line mLine in mText. If you alter the value of mText inside
> the loop, you will see strange and unexpected results in mLine, because the
> engine evaluates mText as a location in memory, and altering mText can alter
> in unexpected ways what is in memory. Things get really ugly after that.
>
> Best to not change the conditions of a repeat loop, except in the scenario
> described by Colin.
>
> Bob
>
>
> On Dec 3, 2010, at 11:15 AM, Warren Kuhl wrote:
>
> > Colin,
> >
> > Thanks....that would work.  I didn't even think to do it this way.
> >
> > Have a great weekend!
> > Warren
> >
> > On Fri, Dec 3, 2010 at 1:09 PM, Colin Holgate <coiin at verizon.net> wrote:
> >
> >>
> >> On Dec 3, 2010, at 1:59 PM, Warren Kuhl wrote:
> >>
> >>> But the repeat still stops at 50.  Is there anyway to increase a repeat
> >> loop
> >>> maximum variable while within the loop?
> >>
> >> How about:
> >>
> >> put 1 into x
> >> put 50 into tCount
> >> repeat while x <=  tCount
> >> if x = 50 then
> >> put 100 into tCount
> >> end if
> >> add 1 to x
> >> end repeat
> >>
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> use-livecode at lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the Use-livecode mailing list