#targetengine specific to Adobe scripts in InDesign, PhotoShop, Illustrator, etc. is not a general Javascript function.
Specifies how to handle all global βthingsβ - not only variables, but also function declarations and any other changes to the global status.
If you use the default main core engine, all globals disappear as soon as the script completes. If you use the session engine, all global variables are retained while the host application continues to run. This means that if you run the script:
#targetengine "session" var test = "test";
and then run the script:
#targetengine "session" alert(test);
you get a window with the message test instead of giving an error
In addition to the two standard "core" and "session" engines, you can create your own, with arbitrary names, so if you run the script
#targetengine "mine" var test = "another test";
and then run
#targetengine "mine" alert(test);
you will get a window with another test message, but if you run it again
#targetengine "session" alert(test);
you get test anyway: there are two different βtestβ global variables: one in the βsessionβ engine and one in the (recently created) βmineβ.
source share