local variables

Kee Nethery kee at kagi.com
Mon Dec 28 20:47:36 EST 2009


OK this is weird, also in 4.0. A local variable appears to be treated as a global variable.

local x, y, myvariable

on mouseup
  put empty into myvariable
  repeat with x = 1 to 1000
    repeat with y = 1 to 1000
      put x && somefunction(y) & return after myvariable
    end repeat
  end repeat
end mouseup

on somefunction y
  repeat with x = y down to 1
    add 1 to y
  end repeat
  return y && x
end somefunction

In code that looks a lot like this, x in the mouseup gets reset to 1 after somefunction(y) is called. If x was a global, OK I'd expect that, but I have to declare x a local to use it and it is being treated as a global. Also, x appears twice in the variable section of the debug window. What should I be doing to get the behavior I used to get in 2.9?

Thanks, Kee





More information about the Use-livecode mailing list