Change iteration variable

t is already a global variable if the snippet you posted is not in a function. To make it a local variable, put your code in a function:

function foo()
    t = 1
    while t <= 200
        println(t)
        if t == 1
            println("Hei")
        elseif t == 140
            t = 150
        else
            println("Hei")
        end
        t += 1
    end
end
foo()

And it will work

4 Likes