Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Replace tabs on the same selected line to A) B) C) D) E)

Return to Member Forum

  • Author
    Posts
    • #96419
      Alican Ozturk
      Participant

      I’m sorry for my bad english. I have a question, I want to change the tab stops on the selected line to A) B) C) D) E), but if there are any graphics on this line, java code will delete this graphic. Thank you for every recommendation

      The script I created from the code I found

      app.findGrepPreferences = NothingEnum.nothing; // now empty the find what field!!! that’s important!!!
      app.changeGrepPreferences = NothingEnum.nothing; // empties the change to field!!! that’s important!!!

      // some settings
      app.findChangeGrepOptions.includeFootnotes = false;
      app.findChangeGrepOptions.includeHiddenLayers = false;
      app.findChangeGrepOptions.includeLockedLayersForFind = false;
      app.findChangeGrepOptions.includeLockedStoriesForFind = false;
      app.findChangeGrepOptions.includeMasterPages = false;

      var greps = [
      {“findWhat”:”^.”,”changeTo”:”A) $0″},
      {“findWhat”:”(?=.*$)”,”changeTo”:”$0B) “},
      {“findWhat”:”.+?(?=.*$)”,”changeTo”:”$0C) “},
      {“findWhat”:”.+?.+?(?=.*$)”,”changeTo”:”$0D) “},
      {“findWhat”:”.+?.+?.+?(?=.*$)”,”changeTo”:”$0E) “},

      ]

      // loop thru the greps object
      for(var i = 0;i < greps.length;i++){
      // this is like entering the find what text in the UI
      app.findGrepPreferences.findWhat = greps[i].findWhat;

      // this is like entering text in the change to
      app.changeGrepPreferences.changeTo = greps[i].changeTo;
      // and now hit the button
      app.selection[0].changeGrep();

      app.findGrepPreferences = NothingEnum.nothing; // now empty the find what field!!! that’s important!!!
      app.changeGrepPreferences = NothingEnum.nothing; // empties the change to field!!! that’s important!!!

      for example
      line included

      1 2 3 4 5

      script change this line

      A) 1 B) 2 C) 3 D) 4 E) 5

    • #96426
      Peter Kahrel
      Participant

      To remove anchored objects, look for ~a and replace with nothing.

    • #96433
      Alican Ozturk
      Participant

      Thank you very much for your advice Mr Peter Kahrel,
      but I think I misrepresented the problem
      I don’t want to delete anchored objects
      I want to save anchored objects when replacing :)

    • #96434

      var mySel = app.selection[0];

      mySel.insertionPoints[0].contents = “A) “;

      app.findGrepPreferences = app.changeGrepPreferences = null;

      app.findChangeGrepOptions.includeFootnotes = false;
      app.findChangeGrepOptions.includeHiddenLayers = false;
      app.findChangeGrepOptions.includeLockedLayersForFind = false;
      app.findChangeGrepOptions.includeLockedStoriesForFind = false;
      app.findChangeGrepOptions.includeMasterPages = false;

      var myGreps = [
      {“findWhat”:”t(?=.*$)”,”changeTo”:”B) “},
      {“findWhat”:”t.+?Kt(?=.*$)”,”changeTo”:”C) “},
      {“findWhat”:”t.+?t.+?Kt(?=.*$)”,”changeTo”:”D) “},
      {“findWhat”:”t.+?t.+?t.+?Kt(?=.*$)”,”changeTo”:”E) “}
      ],
      G = myGreps.length, g;

      for ( g = 0; g < G; g++ ) {
      var myGrep = myGreps[g];
      app.findGrepPreferences.findWhat = myGrep.findWhat;
      app.changeGrepPreferences.changeTo = myGrep.changeTo;
      mySel.changeGrep();
      app.findGrepPreferences = app.changeGrepPreferences = null;
      }

      // (^/)

    • #96437

      Small correction! Take this one!

      —— Script ———————————————-

      var mySel = app.selection[0];

      mySel.insertionPoints[0].contents = “A) “;

      app.findGrepPreferences = app.changeGrepPreferences = null;

      app.findChangeGrepOptions.includeFootnotes = false;
      app.findChangeGrepOptions.includeHiddenLayers = false;
      app.findChangeGrepOptions.includeLockedLayersForFind = false;
      app.findChangeGrepOptions.includeLockedStoriesForFind = false;
      app.findChangeGrepOptions.includeMasterPages = false;

      var myGreps = [
      {“findWhat”:”t(?=.*$)”,”changeTo”:”$0B) “},
      {“findWhat”:”t.+?Kt(?=.*$)”,”changeTo”:”$0C) “},
      {“findWhat”:”t.+?t.+?Kt(?=.*$)”,”changeTo”:”$0D) “},
      {“findWhat”:”t.+?t.+?t.+?Kt(?=.*$)”,”changeTo”:”$0E) “}
      ],
      G = myGreps.length, g;

      for ( g = 0; g < G; g++ ) {
      var myGrep = myGreps[g];
      app.findGrepPreferences.findWhat = myGrep.findWhat;
      app.changeGrepPreferences.changeTo = myGrep.changeTo;
      mySel.changeGrep();
      app.findGrepPreferences = app.changeGrepPreferences = null;
      }

      // (^/)

    • #96438
      Alican Ozturk
      Participant

      Obi-wan Kenobi

      you are unbelievable

      Endless thanks :)))

Viewing 5 reply threads
  • You must be logged in to reply to this topic.
Forum Ads