Check PS Version Prior To Running Script?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Colorguy

Check PS Version Prior To Running Script?

Post by Colorguy »

I have a few scripts that will only run with CS5 or higher.

As opposed to someone using an earlier PS version and attempting to run them receiving the usual cryptic error, is there a way the script can check if CS5 or higher is installed, and if not, display a text box stating the script requires PS CS5 or higher to run?

Any help is appreciated as I really don't have a clue with this one. Thanks.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Paul MR

Check PS Version Prior To Running Script?

Post by Paul MR »

Here is one way...

Code: Select allif(app.version.match(/\d+/) <12){
alert("You need Photoshop CS5 or above to run this script!");
}else{
    main();
}
function main(){
    alert("Hi you are running Photoshop CS5 or above");
}
Colorguy

Check PS Version Prior To Running Script?

Post by Colorguy »

Thanks for the fast response. That script does check for the version, but it doesn't stop the script from running if using PS versions below CS5. The first 25 or so functions of my scripts still continue to run until it reaches commands not compatible with PS versions below CS5.
Paul MR

Check PS Version Prior To Running Script?

Post by Paul MR »

You must be using the code wrong as it does work, it will not run main(); unless it meets the version check.
Colorguy

Check PS Version Prior To Running Script?

Post by Colorguy »

I put the code at the top of my script then attempted to run the script using CS4.

It does trigger an alert box with "You need Photoshop CS5 or above to run this script!" along with an OK button.

If clicking OK, the script then continues to run however until it reaches a point not compatible with CS4.

What am I doing wrong?
Paul MR

Check PS Version Prior To Running Script?

Post by Paul MR »

You need to look at the example again.
All your code should be in a function called main();
Try running the example and you will see how it works.
Colorguy

Check PS Version Prior To Running Script?

Post by Colorguy »

Okay, all my code is defined by main();

Now I'm getting this error following the You need CS5 window...

Error 27: Stack overrun.
Line:0
->
Paul MR

Check PS Version Prior To Running Script?

Post by Paul MR »

Without seeing the code it is impossible to see what you are doing, have you tried the example code?
Colorguy

Check PS Version Prior To Running Script?

Post by Colorguy »

The script is much too long to post here. I'll write up a small test script that includes some CS5-6 specific events and try it again. I'll post it here sometime tomorrow if I can get it working or not. Thanks for the help.
Paul MR

Check PS Version Prior To Running Script?

Post by Paul MR »

The problem is not CS6 events, the main function should not run at all, you still need to study the example.