Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: I need js global vars in PS-64bit CS6, but they aren't staying in memory.

$
0
0

Yes that is normal. Most of the time all you want in the startup script is to define properties and methods. The script does not do anything other than maybe some needed setup.

 

For example if you wanted a startup script to keep track of open documents your script may look something like this.

 

var milesScriptObject = {};

milesScriptObject.openDocuments = [];

milesScriptObject.docCount = function(){ return this.openDocuments.length; };

milesScriptObject.add = function( doc ){ this.openDocuments.push(doc);};

milesScriptObject.remove = function( doc ){

    for(var arrayIndex=0;arrayIndex< this.openDocuments.length;arrayIndex++){

        if(this.openDocuments[arrayIndex]===doc) this.openDocuments.splice(arrayIndex,1);

    }

};

 

Then in another script you access those methods and properties.


Viewing all articles
Browse latest Browse all 27456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>