• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

#target bridge problem

Engaged ,
Jan 17, 2022 Jan 17, 2022

Copy link to clipboard

Copied

Hello,

 

I have a problem with a javascript (extendscript) I wrote for AI, PS, ID and IC. See https://www.behance.net/gallery/134777275/Javascript-for-AI-PS-and-ID-restore-files-from-CClib

 

To get it run in Bridge as well I added "target bridge". AI and PS will ignore this line, but ID and IC will start the Bridge instead to run it in ID or IC.

I created two versions: one for AI, PS, ID and IC (without #target) and one for Bridge (with #target).

But I think, that can't be the best solution, can it?

 

If there no #if #else like in C++ to check which #target is the right one?

 

– j.

TOPICS
Problem or error , Scripting

Views

286

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 17, 2022 Jan 17, 2022

Copy link to clipboard

Copied

How are you loading and invoking this script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 17, 2022 Jan 17, 2022

Copy link to clipboard

Copied

Just a simple example

#target bridge
alert("Hello world!");

I start the .jsx file by double click in adobe bridge (A), 

I get the warning (B) and than I see the jsx running (C).

(Screenshot from a other project.)

A127-2D-JS-BR-screen1.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 17, 2022 Jan 17, 2022

Copy link to clipboard

Copied

Don't do that.

You can load your script in the Bridge Startup Scripts folder or one of the Adobe folders that all CC apps look in.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 18, 2022 Jan 18, 2022

Copy link to clipboard

Copied

Your answer is not very helpful, because the reasoning is missing.


In "Adobe Bridge 2021 Javascript Guide" it says that you can also start a JSX from the Bridge Browser, as I did. See screenshot.

 

From what I have learned, Bridge, Photoshop and Illustrator do not have a fixed folder for javascripts. InDesign and InCopy do.

 

My problem is not starting a JSX but how to program it to run the same javascript in Bridge, InCopy, InDesign, Illustrator and Photoshop. The problem is the command "#target", which can either be bypassed via a #if #else depending on the app or there should be another way to make a JSX run in Bridge as well. 

I have already written two JSX that run in four of the five apps (see https://www.behance.net/jensulkriebel), only for Bridge I need a separate version because of one line. That is not purposeful.

– j.

Bildschirmfoto 2022-01-18 um 09.36.36.png

 



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 18, 2022 Jan 18, 2022

Copy link to clipboard

Copied

In the meantime, I have found a solution, but it requires two JSX files:

1. the JSX file that can be executed in AI, IC, ID and PS. I call it "mainScript.jsx".
2. a JSX file that only runs in Bridget and loads and starts the first JSX file. I call this second file "Launcher4Bridge.jsx".

 

Javascript of mainScript.jsx

// this is the main script
// it can be launched in AI, IC, ID and PS
function fMainScript() {
	alert(app.name + " show the ticks " + Date.now());
}
if (app.name != "bridge") { fMainScript(); } // call the main script

 

Javascript of Launcher4Bridge.jsx

#target bridge
#include "mainScript.jsx"
try {
	fMainScript(); // launch main script
}
catch(e) {alert("the script 'mainScript.jsx' was not found."); }

 

However, I would prefer a solution that only needs a JSX file.

– j.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 18, 2022 Jan 18, 2022

Copy link to clipboard

Copied

And there is a new problem:
#include, when inside try { }, is not caught.
Launcher4Bridge.jsx aborts with an error message if the file mainScript.jsx is not found.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 18, 2022 Jan 18, 2022

Copy link to clipboard

Copied

LATEST

I have found a solution without #include. You can find the explanation and the download on my German web page: http://www.computergrafik-know-how.de/javascript-auch-in-adobe-bridge-2022-ausfuehren/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines