// Copyright 2007 // Written by Jeffrey Tranberry // Photoshop for Geeks Version 1.0 /* Description: This script demonstates how to work with operators */ // enable double clicking from the // Macintosh Finder or the Windows Explorer #target photoshop // Make Photoshop the frontmost application // in case we double clicked the file app.bringToFront(); /////////////////////////// // MAIN // /////////////////////////// //creates 3 variables, in this case a 'string'. var a = '5', b = '6', c = '7'; // Use the '+' operator concatenate the // number/strings as a new string '567' alert (a+b+c); //creates 3 variables, in this case 'numeric'. var a = 5, b = 6, c = 7; // Use the '+' operator to give the value // of the added numeric values, in this case 18 alert (a+b+c); // creates 3 variables, in this case // two are 'numeric' and one is a string. var a = 5, b = 6, c = "7"; // Use the '+' operator to give the value // The first two are added to make 11 and 7 // is concatenated on the end to give 117 alert (a+b+c); // Have Photoshop display an alert box that // displays the active document width alert(app.activeDocument.width); // Have Photoshop display an alert box // that displays the active document height alert(app.activeDocument.height); // Have Photoshop display an alert box // that displays the active document // width and height added together alert(app.activeDocument.height + app.activeDocument.width) // Use an 'if' control statement to // determine if the document widht // and height are equal if (app.activeDocument.width == app.activeDocument.height){ alert ('Width and Height are equal'); } else { alert ('Width and Height are not equal'); } // Have Photoshop display an alert box that // displays whether the document height is greater than // the document width and alerts user landscape if false // or portrait if true if (app.activeDocument.height > app.activeDocument.width) { alert ('Image is portrait.') } else { alert ('Image is landscape.') }