UXP: How to create an instance of a class from included js-file?
I’ve written in ExtendScript the include part like this:
In the file ec_general_DEV.jsx, which is the file to be included:
function general (g){
this.g = g;
this.remove_trailing_linefeeds = function (str){ // general_class
while (str.slice(-1).charCodeAt() == 10 || str.slice(-1).charCodeAt() == 13) str = str.slice(0, -1);
return str;
}
... and in the file which is including the ec_general_DEV.jsx:
#target indesign;
#include '/Library/Scripts/Adobe Automation/ec_general_DEV.jsx';
g = {}
INST_gene = new general (g); // New instance
// Example of usage
general_txt = INST_gene.remove_trailing_linefeeds (g.source_PI.rows[39].cells[1].contents) + '\r';
And I'm trying to make it work in UXP environment.
//@include '/Library/Scripts/Adobe Automation/ec_general_DEV.jsx';
Many thanks in advance!
Cheers!
Funtom
