3 Replies Latest reply on Nov 22, 2008 1:26 PM by George_Johnson

    Help with Document Javascript

    fjcunninghamjr Level 1
      I have enter this script in the document level javascript editor, but can't get it to save. Can someone verify the scripting is correct. I am looking to expire the document I created on 12/31/2008.
      Thanks
      Frank

      function Expire(sExpirationDate, cFormat)
      {
      //Get the Current Date and Time value
      var fNow=New Date().valueOf();
      //Setup End Date
      var fEnd=util.scand(cFormat, sExpirationDate).valueOf();
      var bExpired=false; //default logical value for expiration)

      //see if the current date
      if(fNow>fEnd){
      bExpired=True;
      }
      return bEpired; //return expiration status
      }
      //set expiration date string format "mm/dd/yyyy"
      var cExpiration = 12/31/2008;

      // excute check expiration code
      if (Expire(cExpiration, mm/dd/yyy) ) {
      app.alert(This application has expired)
      }
        • 1. Re: Help with Document Javascript
          George_Johnson MVP & Adobe Community Professional
          > var fNow=New Date().valueOf();

          Tht should be:

          var fNow = new Date().valueOf();

          > if (Expire(cExpiration, mm/dd/yyy) ) {

          if (Expire(cExpiration, "mm/dd/yyyy") ) {

          > var cExpiration = 12/31/2008;

          var cExpiration = "12/31/2008";

          All of the quotes in the code are incorrect. You probably copied & pasted the code from a PDF or something.

          George
          • 2. Re: Help with Document Javascript
            fjcunninghamjr Level 1
            I redid the scripting by now I am getting the error Missing ) after argument list 20: at line 21

            My line 21 is above the last } in the code but when I try to enter the ) on line 21 I get the same error on the same argument and same line.





            {function Expire(sExpirationDate, cFormat)

            {

            //Get the Current Date and Time value

            var fNow = new Date().valueOf();

            //Setup End Date

            var fEnd=util.scand(cFormat, sExpirationDate).valueOf();

            var bExpired=false; //default logical value for expiration)



            //see if the current date

            if(fNow>fEnd){

            bExpired=True;

            }

            return bEpired; //return expiration status

            }

            //set expiration date string format mm/dd/yyyy

            var cExpiration = 12/31/2008;



            // excute check expiration code

            if (Expire(expiration, 12/31/208) ) {

            app.alert (This application has expired)



            }
            • 3. Re: Help with Document Javascript
              George_Johnson MVP & Adobe Community Professional
              I did not mean for you to get field of the quotes, but rather to use the correct ones. All of the strings in the code need quotes around them.

              Also, you need to use true, not True. Better yet, get rid of it altogether. Try the following:


              function Expire(sExpirationDate, cFormat) {

                  //Get the Current Date and Time value
                  var Now = new Date();

                  // Setup End Date
                  var End = util.scand(cFormat, sExpirationDate);

                  // Will return true if current date is after expiration
                  return (Now > End);

              }

              // Set expiration date string format mm/dd/yyyy
              var cExpiration = "12/31/2008";

              // Execute check expiration code
              if (Expire(cExpiration, "mm/dd/yyyy")) {
                  app.alert("This application has expired!", 3);
              }


              George