Skip to main content
Participant
March 3, 2014
Question

Console Output

  • March 3, 2014
  • 2 replies
  • 11454 views

Is there a something like a  "Trace" statement for the JavaScript console in the ExtendScript Toolkit so I can output the value of variables to the console?  I'm using some alert boxes but that's kina'  clunky.   Thanks.

This topic has been closed for replies.

2 replies

Tom Ruark
Inspiring
March 4, 2014

I had this routine in a Logger object for debugging. You can change the print to $.write or $.writeln as xbytor states. This way you get output in ESTK when running in another point product.

// output to the ESTK console

this.print = function( inMessage ) {

if ( app.name == "ExtendScript Toolkit" ) {

print (inMessage);

} else {

var btMessage = new BridgeTalk();

btMessage.target = "estoolkit";

btMessage.body = "print(" + inMessage.toSource() + ")";

btMessage.send ();

}

Pedro Cortez Marques
Legend
March 4, 2014

By the way, the length of the message supported by the ESTK console is limited.

Is it possibel to extend that to more length?

ESTK 4.2.12

Inspiring
March 3, 2014

$.writeln();

Participant
June 22, 2014

Is $.writeln supposed be work from a js in an html5 panel ?

Thanks

Tom Ruark
Inspiring
June 24, 2014

Unless I'm doing this wrong, when I put a $.writeln() statement in a jsx file that is called from html js (for the extension panel), it does nothing other than make the script stop.  Only Alert() seems to work to get info back about the script if run from an extension panel.


My mistake. Photoshop JSX, not directly. If you run your script directly from ESTK (target Photoshop) then they will show. This is how I usually debug.

Create a BridgeTalk message and send it to ESTK. You can opt to actually Launch ESTK, probably not something for production code, or see if ESTK is already running and send if it is. Something like this:

// might need to escape and encode the inMessage as well to deal with double quotes and single quotes in inMessage

function MyWriteln(inMessage) {

     // comment this out for production code

     if ( ! BridgeTalk.isRunning( "estoolkit" ) )

         BridgeTalk.launch( "estoolkit" );

  

     if ( BridgeTalk.isRunning( "estoolkit" ) ) {

         if ( app.name == "ExtendScript Toolkit" ) {

             $.writeln("help me " + inMessage);

       } else {

             var bt = new BridgeTalk;

             bt.body = "$.writeln('help me : " + inMessage + "');";

             bt.target = "estoolkit";

       bt.send();

       }

     }

}