I don't understand the scope rules for variables in LCServer (either that or I've found a bug that is confusing me :-)

I expected that variables which were (implicitly) declared and set within a script would be available within that script, and within handlers of that script (i.e. like script locals in a normal stack script).

So in the normal case I have a file (mainfile1.lc) which has
<?livecode
put "123" into lang["a"]
put "456" into lang["b"]

put "main file direct" && the number of lines in the keys of lang & "<br>" & CR

on plang pD
put "main file in handler" && the number of lines in the keys of lang & "<br>" & CR
end plang

plang "a"
?>

and, as expected, that produces

main file direct 2
main file in handler 2

However, if I take the two 'put' statements, and place them in a file, which I then include into my file, I get
within some file 2
main file direct 2
main file in handler 0

mainfile2.lc

<?livecode
include "somefile.lc"

put "main file direct" && the number of lines in the keys of lang & "<br>" & CR

on plang pD
put "main file in handler" && the number of lines in the keys of lang & "<br>" & CR
end plang

plang "a"
?>


somefile.lc

<?livecode

put "123" into lang["a"]
put "456" into lang["b"]

put "within some file" && the number of lines in the keys of lang &"<br>" & cr

I have (repeatedly) read the dictionary entry for 'local', but can't make enough sense of it to explain this behaviour - either why it should happen, or to be sure that it shouldn't happen :-)

Any help much appreciated, thanks.
-- Alex.




_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to