2

I am getting a "General Photoshop error occurred. This functionality may not be available in this version of Photoshop." error when I run the following code:

var watermarklineGroup  = app.activeDocument.layerSets.getByName('WATERMARK.LINE');
var snGroup             = app.activeDocument.layerSets.getByName('SERIAL NUMBERS');

var wmLayerOne          = watermarklineGroup.layers[0];
var wmLayerTwo          = watermarklineGroup.layers[1];
var wmLayerThree        = watermarklineGroup.layers[2];
var wmLayerFour         = watermarklineGroup.layers[3];
var wmLayerFive         = watermarklineGroup.layers[4];
var wmLayerSix          = watermarklineGroup.layers[5];
var wmLayerSeven        = watermarklineGroup.layers[6];
var wmLayerEight        = watermarklineGroup.layers[7];

var snLayerOne          = snGroup.layers[0];
var snLayerTwo          = snGroup.layers[1];
var snLayerThree        = snGroup.layers[2];
var snLayerFour         = snGroup.layers[3];
var snLayerFive         = snGroup.layers[4];
var snLayerSix          = snGroup.layers[5];
var snLayerSeven        = snGroup.layers[6];
var snLayerEight        = snGroup.layers[7];

var intFirstSetOfFive   = CreateRandom5 ();
var intSecondSetOfFive  = CreateRandom5 ();
var intThirdSetOfFive   = CreateRandom5 ();


(function main(){        
    WriteGeneratedNumbers();
})();


function CreateRandom5(){
    min = Math.ceil(10000);
    max = Math.floor(99999);
    return Math.floor(Math.random() * (max - min));
}

function WriteGeneratedNumbers(){
    for (var i = 0; i>8; i++){        

        snGroup.layers[i].textItem.contents             = intFirstSetOfFive + " " + intSecondSetOfFive + " " + intThirdSetOfFive;

        watermarklineGroup.layers[i].textItem.contents  = intFirstSetOfFive + intSecondSetOfFive + intThirdSetOfFive;

        alert(snGroup.layers[i].textItem.contents);
        alert(watermarklineGroup.layers[i].textItem.contents);

        intThirdSetOfFive = CreateRandom5 ();
        i++;
     }
}

Currently the variables are redundant, but I just wanted to refresh on my JS (its been 10 years). I dont have any styling on my text layers.

ScreenShot of Layers Panel

Kenny J
  • 21
  • 3
  • Have you tried resetting your Photoshop settings by holding _ctrl + alt + del_ while starting Photoshop, and then re-running your script. Holding down those key combinations at startup will tell Photoshop to delete it's preference file and create a new one. So you may want to make a copy of your prefs file before trying this. There's no references in your code that are not available in the most recent version of PhotoShop, which seems to suggest something wrong with your prefs file. – RobC Feb 14 '18 at 12:24
  • I think you mean ctrl+alt+shift. – Kenny J Feb 14 '18 at 13:03
  • I do, good catch! Btw, I don't encounter the error message and the script successfully runs to completion (however, it doesn't do anything). – RobC Feb 14 '18 at 13:10
  • Right, when I debug the app, it jumps right over the WriteGeneratedNumbers() function and I dont know why. – Kenny J Feb 14 '18 at 19:18
  • Nevermind, I had greater than, and it should've been less than, lol. Thanks a lot RobC – Kenny J Feb 14 '18 at 19:21

0 Answers0