kylomas Posted November 30, 2012 Posted November 30, 2012 (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 November 30, 2012 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
Andreik Posted November 30, 2012 Posted November 30, 2012 (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 November 30, 2012 by Andreik
kylomas Posted November 30, 2012 Author Posted November 30, 2012 Andreik, Thanks, hitting myself in the head with the RTFM stick... 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now