Skip to main content
Inspiring
September 30, 2010
Answered

[CS5 - JS] What's up with jsxbin?

  • September 30, 2010
  • 1 reply
  • 2539 views

Hi guys,

I did this script for a client.

The script opens a dialog-window to set some options and control how actions are performed on opened files.

I usually give clients the jsx file but this time I want to give him a jsxbin in order to hide the code.

The problem is that when I launch the script as a jsxbin file from Script panel in ID the dialog-window is created then closed immediately.

Obviously this don't happen with the jsx file.

This is how I build my dialog:

dlg = new Window("palette", "ID Script Beta");

dlg.preferredSize = [500, 200];

dlg.closeButton=false;

I tried the closeButton trick but it didn't work...

I also initialize a dedicated engine at the beginning of the script:

#targetengine "IDScriptBeta";

Any suggestion?

P.S. I have to use the Palette mode when building the dialog because I need it to be active while actions are prformed on documents.

This topic has been closed for replies.
Correct answer tomaxxi

No, you don't have to put shlases on JSX file. You have to put slashes on JSXBIN file. Here is the sample:

function myAlert(myStr){

  alert(myStr);

}

Now convert it to JSXBIN:

@JSXBIN@ES@2.0@MyBbyBnABMAbyBn0ABJBnAEjzFjBjMjFjSjUBfRBVzFjNjZiTjUjSCfAffABC40Bh
AB0AzHjNjZiBjMjFjSjUDAC0EzAEByB

Now, open new JSX file and form it like this:

#targetengine myenginename

app.doScript("@JSXBIN@ES@2.0@MyBbyBnABMAbyBn0ABJBnAEjzFjBjMjFjSjUBfRBVzFjNjZiTjUjSCfAffABC40Bh\
AB0AzHjNjZiBjMjFjSjUDAC0EzAEByB");

Notice slash on the end of the line. You have to put it on each end of line, or you delete linebreaks to get one long line of code.

And that's it.

--

tomaxxi

http://indisnip.wordpress.com/

1 reply

tomaxxi
Inspiring
September 30, 2010

The thing is that you can't include #targetengine inside JSXBIN. Remove #targetengine from script, export your script to JSXBIN open new script and do this:

#targetengine "IDScriptBeta";

app.doScript("/*paste your JSXBIN file here*/");

You will have to delete line breaks in your JSXBIN file or put slash (\) on the end of each line.

Hope that helps.

--

tomaxxi

http://indisnip.wordpress.com/

Inspiring
September 30, 2010

Thanks for the tip Marijan, it worked!

Just another question: I tried to put the slash at the end of every lines like this:

...

dlg.buttons_group.enabled = false;\

var folder_path = folder.absoluteURI;\

var folder_contents = folder.getFiles();\

...

but while debugging it showed me errors so I deleted line breaks and it went good.

Did I do something wrong?

What's the story behind those slashes?

Is there a way to handle all this within just one file?

Thanks again!

tomaxxi
Inspiring
September 30, 2010

Oh wait...

why when I launch the script from ID it automatically open the ExtendToolkit?


I just tested some sample script and it works just fine.

Does it give you some error?

--

tomaxxi