Copy link to clipboard
Copied
I'm trying to debug some javascripting we are doing to help out art pipeline.
I'm using a startsWith() method that seems to work fine in a stand alone js test script run within VS Code, but the exact same lines seem to fail or error silently when called within Photoshop (a call to the script handled by the Script Event Manager). Running PS 21.0.3 20200115.r.91.
One of the working theories is that PS may have a different version of JS it ships with that accounts for different behavior. If anyone can help me track down the JS version to help prove/disprove the theory, that would be grand.
{Thread renamed by moderator} 🙂
2 months ago 20 years passed and we still use ECMAScript 3 (1999)
Copy link to clipboard
Copied
Hi Peter,
Not sure how to check the supported Javascript version in Photoshop, however, you may have a look at this article and see if it helps: https://www.adobe.com/devnet/photoshop/scripting.html
Regards,
Sahil
Copy link to clipboard
Copied
Hey,
thanks for the link. I've already been looking at those docs and unfortuantley can't find any ref to supported JavaScript versions.
Pete
Copy link to clipboard
Copied
2 months ago 20 years passed and we still use ECMAScript 3 (1999)
Copy link to clipboard
Copied
Ahhh. That might explain it.
From what I can gather on-line startsWith() was introduced in or around ECMA6 and was still not supported by all browsers in 2009. If the Javascript PS supports pre-dates that by even further (an addt'l 10 yrs?!) then it is likley not supported.
pete
Copy link to clipboard
Copied
You could implement:
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
value: function(search, rawPos) {
var pos = rawPos > 0 ? rawPos|0 : 0;
return this.substring(pos, pos + search.length) === search;
}
});
}
if not the fact first you had to implement defineProperty, and then other prototypes like call etc
Copy link to clipboard
Copied
Thanks for the code snippet. I've quickly got a windowed workflow running with search() method right now since startsWith() was a non-starter. I'll look this over and see if I can use it. Appreciate the help!
cheers,
Pete
Copy link to clipboard
Copied
$.about() shows the Extendscript About box
Find more inspiration, events, and resources on the new Adobe Community
Explore Now