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

adding empty lines (paragraphs)

Return to Member Forum

  • Author
    Posts
    • #63459
      Gert Verrept
      Member

      Hi,

      I'm wondering if it's possible to script this:

      When I select a piece of text, the info panel gvies me the number of lines selected. What I then have to do in the opposite frame is adding the same number of empty lines, so that the next paragraph lines up with the paragraph in the other frame.

      Why? In one frame I have “old text” in the other frame I have the “new” text and all the paragraphs have to line up (on the even pages the french text is put, on the odd pages the Dutch equivalent). Using tables is not an option due to previous automatisations.

      What I would like to have is, when I have put an insertion point (with the type tool) in the opposite frame, a script which asks for the numbers of lines to be added (info panel), and adds that number at the insertion point of that frame. If the script would be able to give me a dialog box with the number of lines already filled in (but editable), even better.

      Simply put, if the info panel shows me 40 lines, I have to put 40 “enters” (with the same parastyle) in the opposite frame to align both next paragraphs.

      If there's another solution then a script, I'd loved to hear it too.

      thnkx

    • #64241
      Eugenyus
      Member

      Run the script. Select a text, that shows you the number of lines you need to add, press the button “Remember the Number of Lines” (after that you may press “Cancel” to cancel your choice). Than select an insertion point where you need to add empty paragraphs and press the button “Insert Empty Lines” (sorry for my english :) ).

      #targetengine “addemptylines”
      //(c) Eugenyus,2013,v1.0. Eugenyus@mail.ru
      var myEventHandler = function(ev){
      try{numsellines.text = String(doc.selection[0].lines.length);}catch(e){numsellines.text = “0″;}
      }

      var doc = app.activeDocument;
      try{var numoflines = String(doc.selection[0].lines.length);}catch(e){var numoflines = “0″;}
      var w = new Window(“palette”);
      w.orientation = “row”;
      w.add(“statictext{text:”number of lines selected: “}”);
      var numsellines = w.add(“statictext{text:”+numoflines+”,characters:4}”);
      var remBut = w.add(“button”,undefined,”Remember the Number of Lines”);
      var remembed = false;
      remBut.onClick = function(){
      if (!remembed){
      doc.removeEventListener('afterSelectionChanged', myEventHandler);
      remBut.text = “Cancel”;
      }
      else{
      doc.addEventListener('afterSelectionChanged', myEventHandler);
      remBut.text = “Remember the Number of Lines”;
      }
      remembed = !remembed;
      app.activate();
      }
      var addBut = w.add(“button”,undefined,”Insert Empty Lines”);
      addBut.onClick = function(){
      if ((remembed)&&(doc.selection[0].constructor.name == “InsertionPoint”)){
      for(i=0;i<Number(numsellines.text);i++){
      doc.selection[0].contents+=”r”;
      }
      remBut.text = “Remember the Number of Lines”;
      remembed = !remembed;
      doc.addEventListener('afterSelectionChanged', myEventHandler);
      }
      app.activate();
      }
      doc.addEventListener('afterSelectionChanged', myEventHandler);

      w.onClose = function(){
      doc.removeEventListener('afterSelectionChanged', myEventHandler);
      }

      w.show();

    • #64251
      Gert Verrept
      Member

      Thnkx,

      I'll give a try and let you know the result.

      gert

    • #64264
      Gert Verrept
      Member

      Splendid, works just fine.

      Thnkx a million, we just changed “0” in 0 in the following lines:

      try{numsellines.text = String(doc.selection[0].lines.length);}catch(e){numsellines.text = 0;}

      try{var numoflines = String(doc.selection[0].lines.length);}catch(e){var numoflines = 0;}

      gert

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