Testing version

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

Larry Ligon

Testing version

Post by Larry Ligon »

I posted a script to the Adobe Studio Exchange for CS and CS2. Some Bozo posted a negative review because it gave him a "nasty error" when he tried to run it on version 7 even though it was clearly stated that it was for CS and CS2.

This is my attempt to "Idiot Proof" my scripts, so that the user will know that he is trying to run it on the wrong version of Photoshop. This code snippet test to make sure that the version is CS2.

Code: Select allvar versionGood = false;
try{
var appVersion = app.version.split(".");
if (appVersion[0] == "9") {versionGood = true};
 }
catch (e) {
alert("This script will not run on Photoshop 7")
};

if (versionGood ) {alert("found good version")}
 else {alert("This only works for Photoshop CS2")};

When you try to use "app.version" in Photoshop 7, you get an error. That's why the try/catch is needed.

You can modify it to make CS the valid version.

Larry
xbytor

Testing version

Post by xbytor »

I do something similar. I use this trio of functions to determine the PS version.

Code: Select allisCS2 = function()  { return version.match(/^9\./); };
isCS  = function()  { return version.match(/^8\./); };
isPS7 = function()  { return version.match(/^7\./); };


so that when I do have a code that won't run in PS7 I do this:

Code: Select allif (isPS7()) {
   throw "This script requires Photoshop CS or later";
}
mlk

Testing version

Post by mlk »

Nice! I'll probably use it as a header on each and every script I make from now on !