Storing Data In A Target Engine - ff6347/extendscript GitHub Wiki
###storing data in a target engine
For exchanging values between scripts you can make use of a targetengine, in which, while the program is active, data can be stored. This advanced solution can have many stumbling stones.
Script one
#targetengine "session01"
var myValue = 0; // new value
alert(myValue); // result is 0
myValue++; // increment by 1
Script two
#targetengine "session01"
alert(myValue); // result is 1
Have a look at this gist and this stackoverflow question