Copy link to clipboard
Copied
I just started testing indesign server and my first noob question is how to get the path to my script for easier includes.
With a script in indesign I would do something like this:
var basePath = File(app.activeScript).parent + '/';
But app.activeScript is not defined in indesign server?
Copy link to clipboard
Copied
Perhaps $.filename?
Copy link to clipboard
Copied
I get undefined.
Copy link to clipboard
Copied
Sorry, typo: $.fileName
(Not sure if this works on Server, though).
Copy link to clipboard
Copied
No error but no output. I wrote typeof($.fileName) to a file and it is a string but its empty.
I wrote this simple script that gives me a list of all values in an object and a strange/funny thing is that fileName changes after an $.evalFile() to the path of the included file. But if I run it without includes the string is empty.
output($);
function output( str ) {
if( typeof( str ) == 'object') {
var obj = str;
var arr = [];
for( param in obj ) {
try {
arr.push( param + ':\t' + obj[param] );
} catch(e) {}
}
str = arr.join('\n');
}
var file = File('~/Desktop/output.txt');
file.open('w');
file.write(str);
file.close();
}
Copy link to clipboard
Copied
Funny enough the DOM for IDS stands app.activeScript is a valid property but when I try to use it I also get an error.
If you need to load libraries, you may need to use the full path if you can foresee it. Or rebuilt it dynamically using some base uri info that can be passed as argument to you indesign call.
FWIW
Loic