7 Replies Latest reply on Sep 9, 2008 3:22 PM by Seth McGraw

    Help with Prompt and Save As please

    Seth McGraw Level 1
      I need to prompt user (either with indesign cs3 prompt or or OS (would prefer to learn how to use ID prompts) to enter a 5 digit number. that number would need to be verified of 5 digits and have the document save as to a user selected location with a specific naming protocol: 12345_400-000-000.indd (the digits after the 400 are the 3 digit page numbers of the document.

      example: Job#_Category-page range (pg 122-129)
      would be: 12345_400-122-129

      I'm a newb, please take babysteps.
      Thanks
        • 1. Re: Help with Prompt and Save As please
          Loic.Aigon Adobe Community Professional
          Hi prompt is easy :
          var p = prompt("enter something please", "default text", "prompter 1,0");

          I am not skilled with grep but it sounds helpful for checking the digit. Once check is ok, creating the file name is not really a pain in the ***.

          var doc = app.activeDocument;
          var pg = doc.pages;
          var usrfolder = Folder.selectDialog();
          var folderpath = usrfolder.path;
          var filename = folderpath + "/" +p + "_400-"+pg[0].name + "-"+pg[-1].name + ".indd";
          doc.save(File(filename));

          Hope it helps
          Loic
          • 2. Re: Help with Prompt and Save As please
            Seth McGraw Level 1
            Thanks on the filesave especially. I'm guessing it's much easier to just use the OS prompt instead of the prompt in IDcs3.

            Anyone have any ideas about how to write the function for IDcs3 to verify the 5 digit entry? the objects and keywords are different than the way you would word it for a browser.

            thanks again Loic
            • 3. Re: Help with Prompt and Save As please
              Kasyan Servetsky Level 5
              >Anyone have any ideas about how to write the function for IDcs3 to verify the 5 digit entry?

              See this thread:
              http://www.adobeforums.com/webx?128@@.59b650ea

              Kasyan
              • 4. Re: Help with Prompt and Save As please
                Loic.Aigon Adobe Community Professional
                Hi Seth,
                I think I have the thing :
                if(app.documents.length>0)
                {
                var doc = app.activeDocument;
                var pg = doc.pages;
                fivedg();
                var test = new RegExp(/^\d{5}$/).test(p);
                if(test == true)
                {
                usrfolder();
                if(usrfolder!=null)
                {
                var folderpath = usrfolder.path;
                var filename = folderpath + "/" +p + "_400-"+pg[0].name + "-"+pg[-1].name + ".indd";
                doc.save(File(filename));
                }
                }
                else
                {
                alert("Please enter a valid 5 digits number (ex: 12345)");
                fivedg();
                }
                }

                function fivedg()
                {
                var p = prompt("enter a five digit number please", "00000", "File saver 1.0");
                return p
                }
                function usrfolder()
                {
                var usrfolder = Folder.selectDialog();
                return usrfolder;
                }

                hope it runs well. Loic
                • 5. Re: Help with Prompt and Save As please
                  Loic.Aigon Adobe Community Professional
                  Gosh it has as many chances to run than making you win to the lottery.
                  So I did what I had to : test it before.
                  That's what I did this time and I think I got a good result.

                  if(app.documents.length>0)
                  {
                  var doc = app.activeDocument;
                  var pg = doc.pages;

                  while( check5dg() == false)
                  {
                  alert("Please enter a valid 5 digits number (ex: 12345)");
                  }
                  var usrfolder = Folder.selectDialog();
                  if(usrfolder!=null)
                  {
                  var folderpath = usrfolder.path;
                  var filename = folderpath + "/" +p + "_400-"+pg[0].name + "-"+pg[-1].name + ".indd";
                  doc.save(File(filename));
                  }
                  }
                  function check5dg()
                  {
                  var p = prompt("enter a five digit number please", "00000", "File saver 1.0");
                  return new RegExp(/^\d{5}$/).test(p);
                  }
                  • 6. Re: Help with Prompt and Save As please
                    Loic.Aigon Adobe Community Professional
                    I noticed yesterday that using a dialog could offer a built-in number control.
                    Making a call to a realEditBox and setting its properties like minimumValue:0, maximumValue:99999 will check natively the inpût.
                    If it's not numbers it prompts for error. >99999 prompts for error.
                    But building a dialog just for that goal is probably more time consuming than just use a prompt and check the input.

                    Wha's a pity is that we can't restreign the input to a range of 5 digits (right now, as long as you type in numbers, the string is just bigger and bigger). So the user could not enter anything else than 5 digits.

                    I had a look too to scripting on event, considering that maybe you would like to force your end users to save the file thsi way everytime. So if they want to close or save the file, the script could take control over the application and force user to save the files your way.
                    But it's quite a bit totalitary and not so easy to handle I think so far.

                    What do you think ?

                    Loic
                    • 7. Re: Help with Prompt and Save As please
                      Seth McGraw Level 1
                      I have been out of the loop for a few days. corporate's got me covering tech support for a week or so for a dude's new offspring break. I'll be able to check it tomorrow. I'll let you all know how it turned out. Thanks for the help.

                      Seth