6 Replies Latest reply on Jun 21, 2013 6:40 AM by camilo umaña

    How to fix some scripts not working just in CC?

    camilo umaña Level 1

      Tried to use a well known script in IDCC:

       

      TurnGrepStyles2CharStyles.jsx

       

      and not worked; but in CS6 it was running.

       

      How to fix it?

        • 1. Re: How to fix some scripts not working just in CC?
          Eugene Tyson Adobe Community Professional & MVP

          This is the Script in question

           

          /*

          ------------------------------------------------------------------------------------------ ------------------------

          TurnGrepStyles2CharStyles

          ------------------------------------------------------------------------------------------ ------------------------

          An InDesign CS4 JavaScript by FourAces, The Final Touch 2006

          Based on the original "Turn grep styles to character styles.scpt" AppleScript by Nye Hughes

          Version 1.0.0

           

          Converts all the Paragraph Styles applied GREP Styles to standard Character Style applience.

          ------------------------------------------------------------------------------------------ ------------------------

          */

          if(app.documents.length != 0){

              var myDoc = app.activeDocument;

              var myParaStyles = myDoc.paragraphStyles;

              var myCount = 0;

              var myCharStyleList = "";

              for(i=0; i<myParaStyles.length; i++){

                  var myGrepStyles = myParaStyles[i].nestedGrepStyles;

                  for(n=0; n<myGrepStyles.length; n++){

                      var myGrepFind = myGrepStyles[n].grepExpression;

                      var myFindParaStyle = myParaStyles[i];

                      var myChangeCharStyle = myGrepStyles[n].appliedCharacterStyle;

                      var myGrepChange = NothingEnum.nothing;

                      var myFoundItems = runFindChange(myDoc, myGrepFind, myGrepChange, myFindParaStyle, myChangeCharStyle);

                      myCount = myCount + myFoundItems.length;

                      myCharStyleList = myCharStyleList+"\""+myGrepStyles[n].appliedCharacterStyle.name+"\", ";

                  }

              }

              if(myCount > 0){

                  alert("Applied character styles:\r"+myCharStyleList+"to "+myCount+" instances of Grep Styled text.");

              }

              else{

                  alert("No instances of grep styled characters found.\rNothing Changed.");

              }

          }

          else{

              alert("Where\'s my document?!\rWell, I\'ll actually need one to perform my magic...");

          }

           

          function runFindChange(myObject, FindWhat, ChangetoWhat, FindParaStyle, ChangeCharStyle){

              //Clear the find/change preferences.

              clearFindChangePrefs()

              //Set the find options.

              app.findGrepPreferences.appliedParagraphStyle = FindParaStyle;

              app.findGrepPreferences.appliedCharacterStyle = null;

              app.changeGrepPreferences.appliedCharacterStyle = ChangeCharStyle;

              app.findGrepPreferences.findWhat = FindWhat;

              app.changeGrepPreferences.changeTo = ChangetoWhat;

              return myObject.changeGrep();

          }

           

          /*

          function setFindChangeOptionstoDefaults(){

              var myFindChangeTextOpts = app.findChangeTextOption;

              myFindChangeTextOpts.caseSensitive = false;

              myFindChangeTextOpts.includeFootnotes = true;

              myFindChangeTextOpts.includeHiddenLayers = false;

              myFindChangeTextOpts.includeLockedLayersForFind = false;

              myFindChangeTextOpts.includeLockedStoriesForFind = false;

              myFindChangeTextOpts.includeMasterPages = true;

              myFindChangeTextOpts.wholeWord = true;

          }

          */

           

          function clearFindChangePrefs(){

              //find/change text preferences

              app.findTextPreferences = null;

              app.changeTextPreferences = null;

              //find/change grep preferences

              app.findGrepPreferences = null;

              app.changeGrepPreferences = null;

              //find/change glyph preferences

              app.findGlyphPreferences = null;

              app.changeGlyphPreferences = null;

          }

          • 2. Re: How to fix some scripts not working just in CC?
            Peter Spier Most Valuable Participant (Moderator)

            Since the script plinly says it waws written for CS4 it's not surprinsing that it doesn't work in CC, but there's a really good chance it will work if you make a subfolder in your scripts folder named "Version 6.0 Scripts" without the quotation marks, but it is case-sensitive, and put it in that.

            • 3. Re: How to fix some scripts not working just in CC?
              Peter Spier Most Valuable Participant (Moderator)

              Boy, I really can't type this morning...  plainly says it was written for CS4, and not surprising.

              • 4. Re: How to fix some scripts not working just in CC?
                camilo umaña Level 1

                Peter, they are now present in CC and finely enclosed in the folder. Both were old styles.

                Grep one worked finely  and the another one has an error that in the original thread may be answered:

                 

                app.activeDocument.stories.everyItem().texts.everyItem().applyParagrap hStyle(app.activeDocument.paragraphStyles.item(0), false);

                Thanks for your time.

                • 5. Re: How to fix some scripts not working just in CC?
                  Peter Spier Most Valuable Participant (Moderator)

                  If you copied and pasted that line directly from the script I would say the first thing to do is remove the space between the p and h in applyParagraphStyle. Next would be to remove the s on texts so it says everyitem().text.everyitem(), but I'm not as sure about that. I also think there's an indexer missing from between the praentheses in that section of the code, but I'm not a scripter and I can't tell without seeing more of the script, anyway.

                  • 6. Re: How to fix some scripts not working just in CC?
                    camilo umaña Level 1

                    Yes , something continues wrong but with the another one I could resolve the problem. Thank you.