As just another look at how mind-numbingly idiotic a large proportion of Adobe APIs are, consider this attempt to use BridgeTalk :
var bt = new BridgeTalk();
bt.send();
alert('The message was sent successfully.');
We haven't specified a recipient, and we haven't specified an actual message.
But run the code, and guess what? Apparently, the message was sent successfully.
Especially for such a poorly-documented class as BridgeTalk is, developers rely on meaningful error messages (including input validation error messages) to figure out what's going wrong and how on God's beautiful green earth we're supposed to use the thing.
My original script looked more like this :
function BridgeTalkResultHandler(result)
{
alert('Hurrah! The callback came!' + result.body);
}
var bt = new BridgeTalk();
bt.targetApp = 'illustrator';
bt.body = 'alert("hello");';
bt.onResult = BridgeTalkResultHandler;
bt.send();
alert('The message was sent successfully.');
Translation : get Illustrator to show a message. Just an elementary test.
But plug this into the ExtendScript ToolKit and run it, and all you get is meaningless nonsense.
'The message was sent successfully' is given every time you run it, but Illustrator doesn't budge.
Well, thought I, perhaps Illustrator refuses to interact with the user (e.g. with the alert method) under some circumstances. So I changed the script to app.activeDocument.close(), and I left a document open in Illustrator, so I could see if something happened. Still nothing.
I removed the onResult handler to see if somehow that was causing the problem. Nothing changed.
And I stripped out more and more things, until I got to the code at the start of this article.
The behaviour is identical, for every version of the script.
In other words, BridgeTalk is doing absolutely nothing - not even any validation.
I even tried crazy things like :
bt.targetApp = 'illustraaaaaaaaaaaator';
... but there wasn't any complaint about the non-existent target.
Examples of BridgeTalk are not as plentiful as one might wish for, but my original code looks very much like the few examples I found.
All I can say is : this is typical of Adobe APIs. Poorly documented, counter-intuitive, and requiring wasteful trial-and-error to master.
If it was open-source, or some cheapo product, I'd excuse it. But when they want to charge thousands for their suite of products, you expect a LOT better than this.
Got it working - bt.target is the correct property name, not bt.targetApp. I'm not sure whether I read a bad example, or whether I misread an example, but in either case, my thesis stands - Adobe APIs are a dog to work with except only when everything is working perfectly. A helpful input validation error message, such as 'target property is required', would have saved me valuable time! C'mon Adobe, you know you can do better than this... What's worst is that Microsoft is now actually pretty good at making meaningful error messages (something they were hopeless at ten years ago) - so it's possible to have a moderately-self-documenting API, and that means Adobe has dropped the ball.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment