Jump to content
Sign in to follow this  

[Solved - RTFM] Unable to modify the loop control TO variable

Recommended Posts

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

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?


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

Share this post

Link to post
Share on other sites

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

When the words fail... music speaks

Share this post

Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...