> Is there a way to share global variables in jsxbin files?
I'm afraid I don't get your point. Let's recap:
1) The jsxbin format is nothing but a way to encrypt JS code.
2) Indeed, you cannot use an #include directive on jsxbin files.
3) There are several ways to execute encrypted codes though:
a) app.doScript( File('my/path/to/file.jsxbin') );
b) $.evalFile( File('my/path/to/file.jsxbin') );
c) app.doScript( <jsxbin_string> );
d) eval( <jsxbin_string> );
OK. Now suppose that inc01.jsxbin encodes this declaration:
var a = "foo", b = "bar";
and that inc02.jsxbin encodes this statement:
alert( a + b );
From there, the following script should perfectly work:
/* Main.jsx */ app.doScript( File('my/path/to/inc01.jsxbin') ); app.doScript( File('my/path/to/inc02.jsxbin') ); // => 'foobar'
This proves that the vars a and b are actually 'shared' between inc01.jsxbin and inc02.jsxbin. Don't you get that result?
(Apart from this, note that there is usually no reason to encrypt individual jsxbin files before producing the final script. I find it more convenient to benefit from jsx—clear code—inclusion and to finally export the main script into a single jsxbin.)
This is strange. It did not work in my case.
I'll try it again. Maybe I did something wrong.
Main is also a jsxbin in my case, but I don't
think this is of any influence.
The problem seems to be that the script is running in a targetengine
and that global vars are not shared. Any solution for this.
The problem seems to be that the script is running in a targetengine (...)
Ha-ha! This changes many things!
There are some issues in using jsxbin with targetengine:
(a) Each persistent engine runs within its own namespace,
(b) jsxbin cannot load by itself a persistent engine.