// openDocumentConditional.jsx // Copyright 2007 // Written by Jeffrey Tranberry // Photoshop for Geeks Version 1.0 /* Description: This script demonstates how create a conditional function */ // 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 // /////////////////////////// // run the open documents conditional openDocumentsConditional(); /////////////////////////// // FUNCTIONS // /////////////////////////// function openDocumentsConditional(){ // Because we are doing a for loop later in the // script that processes all open documents // we don't want to have any documents open that // we don't want accidentally processed. Warn the // user if they have an open document and exit // the script with return if (app.documents.length > 0){ alert ("This script requires that there are no open documents to run."); return; } // the condition is false, so there are // no open documents alert("There are no open documents."); }