Jump to content

Recommended Posts

Posted (edited)

Good Evening,

Consider the following code

local $slen = 5

for $1 = 1 to $slen
    ConsoleWrite('Loop # ' & $1 & ' $slen = ' & $slen & @LF)
    if $1 = 2 then $slen += 2
next

The variable ($slen) gets incremented but the loop only runs 5 times, expected 7 times. Because the increment control variable can be modified I expected to be able to modify the loop exit variable. Can someone verify whether or not loop exit control can be modified?

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted (edited)

Yes, you can modified but this value it's read just one time, when the loop starts.

The For loop terminates when the value of variable exceeds the stop threshold. If stepVal or stop is a variable, its value is only read the first time the loop executes.

Edited by Andreik

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...