Skip to main content
Participating Frequently
October 24, 2007
Question

Debugging Javascript on InDesign CS3 Server

  • October 24, 2007
  • 8 replies
  • 3456 views
I, like most developers, need to be able to debug my programs. Thus far I have been opening a file and writing to it if I want to see any debug messages. It looks like this...

my_log = createLogFile("filename",app,true);
add_to_log(my_log, debug_string);
my_log.execute();

This would create a file called "filename.txt", add the value of debug_string to the my_log object, then write the log to a file using execute.

However, this approach is not very helpful when doing loops for example. If I have a loop that is breaking my script and I want to check a value that is changing inside a loop I have to create a file, add the error to the log, and execute (write) the log for each pass in the loop. For instance:

for (var i = 0; i < some_array.length; i++) {
my_log = createLogFile("debug_log"+i, app, true);
add_to_log(my_log, some_array);
my_log.execute();
...
whatever is normally in here
...
}

This is the only way I can figure out which item in my array is breaking the script. So, my ultimate question is this:

How do I debug an InDesign server javascript program? Can I write to STDOUT, or STDERR? Some other way? Thanks for any and all help.

_ Sean
This topic has been closed for replies.

8 replies

Participating Frequently
March 7, 2008
sunilkumarrajup,

Since XMP is off topic from the original message, I have posted a new message with an answer for you.

Susan
Participating Frequently
March 7, 2008
hi SusanDoan thanks for helping,ihave done that with your help,thanks so much.i have one more doubt how to create XMP file,hwo to send my information to xmp file,and how to use the xmp in indesign server,can you tell about that xmp.please..thanks for helping..god bless you
Participating Frequently
March 6, 2008
sunilkumarrajup,

To send a JavaScript script to InDesign Server via SOAP:

1. Startup InDesign Server for use with SOAP by specifying a port:
>indesignserver -port 12345

2. Use the command line application, TestClient, that ships with InDesignServer to send a script to IDS via SOAP:
>testclient -host localhost:12345 c:\myScript.jsx

* for TestClient command line options, simply execute testclient with no options:
>testclient

* for more information, download the IDS SDK from: http://www.adobe.com/devnet/indesign/ and read <SDK>/docs/guides/Intro to InDesign CS3 Server - it contains a section named "Interfacing with InDesign Server through SOAP"

Susan
Participating Frequently
March 3, 2008
hi Sean M Berry,can you tell how to run javascript via soap server.please waiting for your reply.
Inspiring
October 29, 2007
Sorry - I don't know any way to set breakpoints in Extendscript if the javascript comes from anywhere but within Extendscript (now that would be neat Adobe.....). The simpler option is just to capture the script sent across (there are open source network capture tools out there if you can't dump it from the server) and paste it into Extendscript.

Extendscript isn't the best 'ide' in the world, but IMHO being able to view variables, set breakpoints, step through the code, etc is worth a few rough edges'.

Ian
Participating Frequently
October 29, 2007
Ian,

Thanks for the response. I discovered a way to get the output I wanted... just using alert() function. It writes to the STDOUT for indesign server so I just capture that in a file and voila.

However, I am interested in using Extendscript for this as well. I am running the Javascript via the SOAP server and need to know how to capture this in Extendscript. So, if I am running on port 10001, how do I still execute via SOAP and capture output in Extendscript?

Thanks...
Inspiring
October 24, 2007
I presume there is some reason you can't just run the javascript in Extendscript connected to server - can't say I've tried that but there is no reason it shouldn't work. The easier way is to use desktop indesign and extendscript - there are a few differences in the abilities with an emphasis on few.

Ian
Participating Frequently
October 24, 2007
Found the answer to my own question... finally.

I can use use "alert('string')" to send it to the STDOUT.

Hope this helps someone else,

_ Sean