to the end of the block where they have been declared
[...]
if (val_2 == 1) print(1); //error, cos 'val_2' need be declared first
local val_2 = 0; //start of declaration
function test {
local val = 0; //start of declaration
} // <- end of the block
if (val_2 == 0) print(1);
// end of da script/block //
you can use locals, conditions, everything outside of funcs
the only difference i saw (time ago) between global and local declaration is: local is used one time, and global can be used anytime.. (i mean, if you use 'compilestring' with a local, you can't access to change it, but with global variable ye)