No external local variable references allowed here
I'm currently working on some UI, ans I'm using a method that I found in Neil Blevins scripts (SoulBurnScripts), which mean everything is in functions, even all the UI items (rollout, buttons, etc...).
So basicaly, for one script I have this:
global theDialog1 -- predefine the dialog local theUI1 -- predefine the function that will create the UI function OpenClose1 = ( try (destroyDialog theDialog1) catch() theUI1() -- call for the function that create the UI createDialog theDialog1 ) function theUI1 = ( rollout theDialog1 ( ... )--end rollout )--end UI function OpenClose1() -- lunch the script
This worked like a charm, no problem here...
Then I tried another method for some tests, which consist to make this script as two separates scripts, so I get this:
global theDialog1 -- predefine the dialog local theUI1 -- predefine the function that will create the UI function OpenClose1 = ( try (destroyDialog theDialog1) catch() include "C:/Script 1b.ms" theUI1() -- call for the function that create the UI createDialog theDialog1 ) OpenClose()
function theUI1 = ( rollout theDialog1 ( ... )--end rollout )--end UI function
Also work like a charm...
Where I get my issue is when I try to make another script, that will contain all of the others scripts (all are based on the method explain earlier) I made in one RolloutFloater. So for this one I get this:
global theFloater -- predefine the rolloutFloater local theDialog1 -- predefine first rollout local theUI1 -- predefine first UI maker function local theDialog2 --predefine second rollout local theUI2 -- predefine second UI maker function ... function OpenClose = ( if theFloater != undefined then CloseRolloutFloater sZTFloater include "C:/Script01.ms" theUI1() include "C:/Script02.ms" theUI2() ... theFloater = newRolloutFloater ) OpenClose()
So here, if I use the second method, which consist to split a script in two scripts, with the first one that create the Dialog and call for the UI in the other script, my rolloutFloater work when I call the Script 1b with theUI1()
But If I try with the first method, there I have my issue returned by the listener as:
"compile error: No external local variable references allowed here: theUI1"
I don't really understand why I get this with the first method and not with the second, I would say a variable conflict but I'm really not sure...
So is there a way to avoid this using the first method ?
Do I have to change local variable to global ?
And by the way, I saw in MXS Help that it wasn't that good to use global variable, but which is the better case, multiple script files for only one at the end, or globals variables ?
And two last question (at least for now ^^), does the Neil Blevins method for his scripts is good or not really, and do I use it the right way ?
Ok I think I have finish to write my book... sorry for this big post :)