Jump to content
Sign in to follow this  
streetcreeppress

Reading a variable modified inside a loop doesnt work, please help

Recommended Posts

Hi, don't understand why this simple piece of code would not work...

What I am trying to do here, is find the index from the first loop that is not present on the second loop.

I am able to print it inside a loop but I cannot call it again after.

Here is how I set this up;

Global $newVar
Global $switch
For $i = 0 To 6 Step 1
    $switch = 0
    For $x = 0 To 5 Step 1
        If $x == $i Then
            $switch = 1
        EndIf
    Next
    If $switch == 0 Then
        $newVar = $x

       ; this will print.
        ConsoleWrite($newVar & @CRLF)
        Exit
    EndIf
Next

; this will not print!?!?!
ConsoleWrite($newVar & @CRLF)

 

If I run this, I don't get the console print outside/after the for loop... Any ideas why this would not work?

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...