Syntax error in StackSupport.jsx

Discussion of actual or possible Photoshop Scripting Bugs, Anomalies and Documentation Errors

Moderators: xbytor, DavideBarranca, Paul MR


Syntax error in StackSupport.jsx

Postby slehar » Thu Dec 11, 2008 3:21 pm

I've been trying to incorporate some Photoshop javascript functions (in particular Photomerge.jsx) for use in my own code, but when I copied this code segment from StackSupport.jsx, I discovered it contains a severe syntax error that bombs on execution, and yet this code apparently works in the Photoshop Photomerge function!

How can Photomerge be working properly in Photoshop when this part of the code does not?

Code: Select all
// Convert plain string to the alignment key.
// Avoids clients having to load Terminology.jsx
// ((Copied from Adobe Photoshop CS4\Presets\Scripts\Stack Scripts Only\StackSupport.jsx
//  lines 577-589. Steve Lehar 12/10/08))
function stringToAlignmentKey( alignMethod )
   // Today's JavaScript lesson:  You can not use the constants above in the table below, because
   // the parser interns the symbol on the left of the ":" into a new ID, whether or not it's already
   // defined in scope.  The new interned symbols only work as object field IDs ( not
   // array indicies (table[xyz])

   // ((Steve Lehar's comment: ))
   // The following line, (now //commented out) found in the original Photoshop code, BOMBS on execution!
//   var table = {"interactive":kinteractiveStr, "Prsp":keyPerspectiveIndex, "Auto":keyAuto, "spherical":ksphericalStr, "cylindrical":kcylindricalStr, "translation":ktranslationStr, "sceneCollage":ksceneCollageStr};

   // ((Steve Lehar's comment: ))
   // The same line, syntax corrected, runs OK without bombing. What gives?
   var table = {interactive:"kinteractiveStr", Prsp:"keyPerspectiveIndex", Auto:"keyAuto", spherical:"ksphericalStr", cylindrical:"kcylindricalStr", translation:"ktranslationStr", sceneCollage:"ksceneCollageStr"};

   if (typeof(alignMethod) == "string")
      alignMethod = table[alignMethod];
   return alignMethod;

Mike Hale

Syntax error in StackSupport.jsx

Postby Mike Hale » Mon Dec 22, 2008 2:06 am

I know you got your script working but I thought I would explain what went wrong with the code you posted here.

Photomerge has include files, some of which have their own includes.

kinteractiveStr and the others are defined in Terminology.jsx. An example is:

Code: Select all
const kinteractiveStr         = app.stringIDToTypeID("interactive");

so 'var table = {"interactive":kinteractiveStr, ..." fails because kinteractiveStr is undefined.

Your replacement line uses strings ie "kinteractiveStr" instead of app.stringIDToTypeID("interactive"). That may have fixed that line but will still break the script when it uses the table that now has strings instead of TypeIDs.



Syntax error in StackSupport.jsx

Postby slehar » Mon Dec 22, 2008 2:13 pm

Yes, I figured I must have misunderstood something somewhere.

Thanks for clearing it up!

Return to “Photoshop Scripting Bugs and Anomalies”

Who is online

Users browsing this forum: No registered users and 1 guest