1 Reply Latest reply on Jul 18, 2014 8:52 AM by Muppet Mark

    How Can I add a dialog in script?

    Johnwhite Level 1

      Hi, everyone,

       

      I have this script:

       

      var myDialog = app.dialogs.add({name:"Tedious Works",canCancel:true}); // <--------- I think can add a dialog in this line but I don't know the syntax
      with(myDialog){
          with(dialogColumns.add()){
              with(dialogRows.add()){
                 var mySelection = dropdowns.add({stringList:["end digit superscript", "beginning digit superscript", "notes to italic","Initial Cap+ markup","Small Cap + markup","del [ ] + markup","add an EM at beginning"], selectedIndex:0});
             }
         }
      }


      if (myDialog.show() == true)
         
      main();
      function main(){
      var myObject;
      var myCheckSelection = false;
      if(app.documents.length > 0){
        if(app.selection.length > 0){
         switch(app.selection[0].constructor.name){
          case "InsertionPoint":
          case "Character":
          case "Word":
          case "TextStyleRange":
          case "Line":
          case "Paragraph":
          case "TextColumn":
          case "Text":
          case "Cell":
          case "Column":
          case "Row":
          case "Table":
           myObject = app.selection[0];
        if(app.selection && app.selection[0].hasOwnProperty ("tedious_works") );
            tedious_works(); 
          }
        }
      }
      else{
        alert("No documents are open or wrong selection. Please try again.");
      }
      }
      function tedious_works() { 
          if (mySelection.selectedIndex == 0){
         app.findGrepPreferences.findWhat = "\\d$";
         app.changeGrepPreferences.position = 1936749411;
         app.selection[0].changeGrep();
         app.findGrepPreferences = app.changeGrepPreferences = null;
          }
          if (mySelection.selectedIndex == 1){
         app.findGrepPreferences.findWhat = "^\\d";
         app.changeGrepPreferences.position = 1936749411;
         app.selection[0].changeGrep();
         app.findGrepPreferences = app.changeGrepPreferences = null;
          }
         if (mySelection.selectedIndex == 2){
         app.findGrepPreferences.findWhat = "(?i)\\(note.+\\)$";
         app.changeGrepPreferences.appliedCharacterStyle = "Italic";
         app.selection[0].changeGrep();
         app.findGrepPreferences = app.changeGrepPreferences = null;
          }
        if (mySelection.selectedIndex == 3){
         app.findGrepPreferences.findWhat = "(附[註注].+)$";
         app.changeGrepPreferences.appliedCharacterStyle = "Italic";
         app.selection[0].changeGrep();
         app.findGrepPreferences = app.changeGrepPreferences = null;
          }
        if (mySelection.selectedIndex == 4){
         app.findGrepPreferences = app.changeGrepPreferences = null;
         app.findGrepPreferences.findWhat = "\\<a";
         app.changeGrepPreferences.changeTo = "A";
         app.changeGrepPreferences.underline = true;
         app.selection[0].changeGrep();
         app.findGrepPreferences = app.changeGrepPreferences = null;

      //...........................not to show too much

       

       

       

      I want to add a dialog “please select a tedious works” under the bar, see pic:

       

      dialog.jpg

      please tell me what is the syntax?