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

You can only recall a function within a script

Advocate ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

You can only recall a function within a script

My intent is to call only a function that is in an external script

The external test script is called prova.jsx

I would like to recall only this function

Function step1 (enabled, withDialog) {

I tried with this little code but it does not work

#include "prova.jsx"

Function step1 (enabled, withDialog) { (function ()

// script

cTID = function(s) { return app.charIDToTypeID(s); };

sTID = function(s) { return app.stringIDToTypeID(s); };

function Action10() {

function step1(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var desc2 = new ActionDescriptor();

    desc2.putClass(cTID('Md  '), sTID("RGBColorMode"));

    desc2.putUnitDouble(cTID('Wdth'), cTID('#Rlt'), 2200);

    desc2.putUnitDouble(cTID('Hght'), cTID('#Rlt'), 1461);

    desc2.putUnitDouble(cTID('Rslt'), cTID('#Rsl'), 72);

    desc2.putDouble(sTID("pixelScaleFactor"), 1);

    desc2.putEnumerated(cTID('Fl  '), cTID('Fl  '), cTID('Wht '));

    desc2.putInteger(cTID('Dpth'), 8);

    desc2.putString(sTID("profile"), "Adobe RGB (1998)");

    desc1.putObject(cTID('Nw  '), cTID('Dcmn'), desc2);

    executeAction(sTID('make'), desc1, dialogMode);

  };

  function step2(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putClass(sTID("contentLayer"));

    desc1.putReference(cTID('null'), ref1);

    var desc2 = new ActionDescriptor();

    var desc3 = new ActionDescriptor();

    var desc4 = new ActionDescriptor();

    desc4.putDouble(cTID('Rd  '), 255);

    desc4.putDouble(cTID('Grn '), 255);

    desc4.putDouble(cTID('Bl  '), 255);

    desc3.putObject(cTID('Clr '), sTID("RGBColor"), desc4);

    desc2.putObject(cTID('Type'), sTID("solidColorLayer"), desc3);

    var desc5 = new ActionDescriptor();

    desc5.putInteger(sTID("unitValueQuadVersion"), 1);

    desc5.putUnitDouble(cTID('Top '), cTID('#Pxl'), 26.4615627137483);

    desc5.putUnitDouble(cTID('Left'), cTID('#Pxl'), 357.8671875);

    desc5.putUnitDouble(cTID('Btom'), cTID('#Pxl'), 770.695937713748);

    desc5.putUnitDouble(cTID('Rght'), cTID('#Pxl'), 1102.1015625);

    desc5.putUnitDouble(sTID("topRight"), cTID('#Pxl'), -1);

    desc5.putUnitDouble(sTID("topLeft"), cTID('#Pxl'), -1);

    desc5.putUnitDouble(sTID("bottomLeft"), cTID('#Pxl'), -1);

    desc5.putUnitDouble(sTID("bottomRight"), cTID('#Pxl'), -1);

    desc2.putObject(cTID('Shp '), cTID('Rctn'), desc5);

    var desc6 = new ActionDescriptor();

    desc6.putInteger(sTID("strokeStyleVersion"), 2);

    desc6.putBoolean(sTID("strokeEnabled"), true);

    desc6.putBoolean(sTID("fillEnabled"), true);

    desc6.putUnitDouble(sTID("strokeStyleLineWidth"), cTID('#Pnt'), 0);

    desc6.putUnitDouble(sTID("strokeStyleLineDashOffset"), cTID('#Pnt'), 0);

    desc6.putDouble(sTID("strokeStyleMiterLimit"), 100);

    desc6.putEnumerated(sTID("strokeStyleLineCapType"), sTID("strokeStyleLineCapType"), sTID("strokeStyleButtCap"));

    desc6.putEnumerated(sTID("strokeStyleLineJoinType"), sTID("strokeStyleLineJoinType"), sTID("strokeStyleMiterJoin"));

    desc6.putEnumerated(sTID("strokeStyleLineAlignment"), sTID("strokeStyleLineAlignment"), sTID("strokeStyleAlignInside"));

    desc6.putBoolean(sTID("strokeStyleScaleLock"), false);

    desc6.putBoolean(sTID("strokeStyleStrokeAdjust"), false);

    var list1 = new ActionList();

    desc6.putList(sTID("strokeStyleLineDashSet"), list1);

    desc6.putEnumerated(sTID("strokeStyleBlendMode"), cTID('BlnM'), cTID('Nrml'));

    desc6.putUnitDouble(sTID("strokeStyleOpacity"), cTID('#Prc'), 100);

    var desc7 = new ActionDescriptor();

    var desc8 = new ActionDescriptor();

    desc8.putDouble(cTID('Rd  '), 1.89196894643828);

    desc8.putDouble(cTID('Grn '), 2.0312731526792);

    desc8.putDouble(cTID('Bl  '), 1.98355863802135);

    desc7.putObject(cTID('Clr '), sTID("RGBColor"), desc8);

    desc6.putObject(sTID("strokeStyleContent"), sTID("solidColorLayer"), desc7);

    desc6.putDouble(sTID("strokeStyleResolution"), 72);

    desc2.putObject(sTID("strokeStyle"), sTID("strokeStyle"), desc6);

    desc1.putObject(cTID('Usng'), sTID("contentLayer"), desc2);

    executeAction(sTID('make'), desc1, dialogMode);

  };

  // Imposta

  function step3(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(sTID("contentLayer"), cTID('Ordn'), cTID('Trgt'));

    desc1.putReference(cTID('null'), ref1);

    var desc2 = new ActionDescriptor();

    var desc3 = new ActionDescriptor();

    var desc4 = new ActionDescriptor();

    desc4.putDouble(cTID('Rd  '), 45.9766551107168);

    desc4.putDouble(cTID('Grn '), 77.5252944231033);

    desc4.putDouble(cTID('Bl  '), 159.521398544312);

    desc3.putObject(cTID('Clr '), sTID("RGBColor"), desc4);

    desc2.putObject(cTID('FlCn'), sTID("solidColorLayer"), desc3);

    var desc5 = new ActionDescriptor();

    desc5.putInteger(sTID("strokeStyleVersion"), 2);

    desc5.putBoolean(sTID("fillEnabled"), true);

    desc2.putObject(sTID("strokeStyle"), sTID("strokeStyle"), desc5);

    desc1.putObject(cTID('T   '), sTID("shapeStyle"), desc2);

    executeAction(sTID('set'), desc1, dialogMode);

  };

  step1();     

  step2();    

  step3();    

};

Action10.main = function () {

  Action10();

};

Action10.main();

TOPICS
Actions and scripting

Views

953

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

correct answers 1 Correct answer

Community Expert , Aug 01, 2017 Aug 01, 2017

I'm not sure about your code. You have this line that has a function but no braces after the function() to state what's in the function. also function calls aren't capitalized:

Function step1 (enabled, withDialog) { (function ()

Here are two simple scripts where the #include works. If the scripts aren't in the same folder, you have to specify the path name in the #include statement:

function sayBye(){alert('bye')}

function sayHello(){alert('hello')}

This is the other script that calls the above scrip

...

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

I'm not sure about your code. You have this line that has a function but no braces after the function() to state what's in the function. also function calls aren't capitalized:

Function step1 (enabled, withDialog) { (function ()

Here are two simple scripts where the #include works. If the scripts aren't in the same folder, you have to specify the path name in the #include statement:

function sayBye(){alert('bye')}

function sayHello(){alert('hello')}

This is the other script that calls the above script called 'callFile'.

#include 'callFile.jsx'

sayHello()

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
Advocate ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Chuck Uebele

I could not get it to work

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
Community Expert ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

What version of PS are you using? Did you try just my two files?

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
Advocate ,
Aug 02, 2017 Aug 02, 2017

Copy link to clipboard

Copied

LATEST

Works well

It was I who made a small mistake.

Thank you

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