1 Reply Latest reply on Jul 15, 2008 1:13 PM by (Olav_Kvern)

    Help needed to update CS2-script to CS3

      Folks,

      I am no good at scripting myself (its on my to-do-list), but a friend of mine has a problem with this script, that wont work in CS3. I know that the syntax is wrong, but am unable to do solve this. Who can help?

      var thecount = app.documents.length;
      app.changeTextPreferences = NothingEnum.nothing;
      app.findTextPreferences = NothingEnum.nothing;
      var myDocument = app.activeDocument;
      var mysearchitems = ["", "Double Paragraph", "Double Tab", "Double Space", "Para Tab", "Para Space", "? space", "Fullstop Double Space"]
      var mychangeitems = ["", "Single Paragraph", "Single Tab", "Single Space", "Para Tab", " Tab", "Fullstop Single Space"]

      var theClass = myDocument.selection
      if (theClass == ""){
      var searchOptions = ["Document"];
      }
      else {
      var searchOptions = ["Document", "Selection", "Story"];
      }

      //now to create the dialog

      var myDialog = app.dialogs.add({name:"Masterfoods B - zoek en vervang (© Hans de Bijl)", canCancel:true});
      with (myDialog){
      with (dialogColumns.add()){
      with (borderPanels.add()){
      }
      with (borderPanels.add()){
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Zoek:"});
      }
      with (dialogColumns.add()){
      var myvijffindfield = textEditboxes.add({minWidth:180});
      }
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Vervang:"});
      }
      with (dialogColumns.add()){
      var myvijfchangefield = textEditboxes.add({minWidth:180});
      }
      }
      with (borderPanels.add()){
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Zoek:"});
      }
      with (dialogColumns.add()){
      var myzesfindfield = textEditboxes.add({minWidth:180});
      }
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Vervang:"});
      }
      with (dialogColumns.add()){
      var myzeschangefield = textEditboxes.add({minWidth:180});
      }
      }
      with (borderPanels.add()){
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Zoek:"});
      }
      with (dialogColumns.add()){
      var myeighthfindfield = textEditboxes.add({minWidth:180});
      }
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Vervang:"});
      }
      with (dialogColumns.add()){
      var myeighthchangefield = textEditboxes.add({minWidth:180});
      }
      }
      with (borderPanels.add()){
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Zoek:"});
      }
      with (dialogColumns.add()){
      var myninthfindfield = textEditboxes.add({minWidth:180});
      }
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Vervang:"});
      }
      with (dialogColumns.add()){
      var myninthchangefield = textEditboxes.add({minWidth:180});
      }
      }
      with (borderPanels.add()){
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Zoek:"});
      }
      with (dialogColumns.add()){
      var mytienfindfield = textEditboxes.add({minWidth:180});
      }
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Vervang:"});
      }
      with (dialogColumns.add()){
      var mytienchangefield = textEditboxes.add({minWidth:180});
      }
      }
      with (borderPanels.add()){
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Zoek:"});
      }
      with (dialogColumns.add()){
      var myelffindfield = textEditboxes.add({minWidth:180});
      }
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Vervang:"});
      }
      with (dialogColumns.add()){
      var myelfchangefield = textEditboxes.add({minWidth:180});
      }
      }
      with (borderPanels.add()){
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Zoek:"});
      }
      with (dialogColumns.add()){
      var mytwaalffindfield = textEditboxes.add({minWidth:180});
      }
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Vervang:"});
      }
      with (dialogColumns.add()){
      var mytwaalfchangefield = textEditboxes.add({minWidth:180});
      }
      }
      with (borderPanels.add()){
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Zoek:"});
      }
      with (dialogColumns.add()){
      var mydertienfindfield = textEditboxes.add({minWidth:180});
      }
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Vervang:"});
      }
      with (dialogC
        • 1. Re: Help needed to update CS2-script to CS3
          Level 1
          Hi Bert,

          Find and change in InDesign CS3 changed quite a bit from CS2, and scripting changed as well. Tell your friend to look at the examples of find and change in the Text chapter of the Adobe InDesign CS3 Scripting Guide: JavaScript--you can find the PDF and the associated scripts at:

          http://www.adobe.com/products/indesign/scripting/index.html

          ...and click the Scripting Resources tab.

          In brief: the search method was removed, and find and change methods corresponding to the find/change type were added (findText, changeText, findGrep/changeGrep, findGlyph/changeGlyph). The find/change preferences objects were also removed, and preferences objects corresponding to the new find/change types were added (findTextPreferences, changeTextPreferences, findGrepPreferences, changeGrepPreferences, findGlyphPreferences, changeGlyphPreferences).

          Thanks,

          Ole