14 Replies Latest reply on Apr 29, 2008 4:18 PM by Harbs.

    Month/Day/Year Script NOT WORKING IN CS3? NEEP EXPERT HELP

      Can someone help me modify my old script to work in CS3? The script generates in a text box the [week day] [month] [day] [year] (((( Thursday, April 24, 2008 ))))) the below script works in InDesign CS2 but it doesn't work in CS3... I"m stuck, lost, and don't understand why it doesn't work anymore! Im not sure if it's the script or the template - I don't know where to start?

      //DESCRIPTION: Use to insert date into a indesign text box

      if (app.documents.length == 0) { exit() }
      insertDTs(app.documents[0]);

      function insertDTs(aDoc) {
      var curPrefs = aDoc.characterStyles[0].extractLabel("dtprefs");
      if (curPrefs == "") {
      // Doc has no prefs; use saved prefs
      curPrefs = getCurPrefs(File(getScriptPath().absoluteURI.replace(/Insert\.jsx/, "Prefs.txt")));
      } // end if curPrefs
      var prefParts = curPrefs.split("\n");
      if (prefParts[2] != "[None]") {
      insertIt(aDoc, prefParts[0], prefParts[2]);
      }
      if (prefParts[3] != "[None]") {
      insertIt(aDoc, prefParts[1], prefParts[3]);
      }

      function insertIt(aDoc, formString, cStyleName) {
      var formStrings= ["Day, Month, Year"]
      var theFuncs = [dayMonthYear]
      var charStyleStrings = aDoc.characterStyles.everyItem().name
      if (indexOf(charStyleStrings, cStyleName) < 1) { return } // style not found or is No Style var func = indexOf(formStrings, formString); if (func < 0) { return } // requested form not recognized var dateString = theFuncs[func](new Date()); app.findPreferences = app.changePreferences = null; aDoc.search("", false, false, dateString, {appliedCharacterStyle:cStyleName}); } // end insertIt

      function dayMonthYear(date) {
      date.setDate(date.getDate()+1);
      // returns dayName, monthName date, year
      var myDateString = date.toLocaleDateString();
      myParts = myDateString.split(" 0");
      if (myParts.length != 1) {
      myDateString = myParts[0] + " " +myParts[1];
      }
      return myDateString.slice(0,-5) + "," + myDateString.slice(-5);

      }

      function indexOf(array, find,offs) {
      for( var i = offs == undefined ? 0 : offs; array.length > i; i++ ) {
      if( array[i]==find ) {return i}
      }
      return -1;
      }

      function getScriptPath() {
      // This function returns the path to the active script, even when running ESTK
      try {
      return app.activeScript;
      } catch(e) {
      return File(e.fileName);
      } // end try
      } // end getScriptPath

      } // end insertDTs