🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #18359

Re: AS Set crieria for new line......

#18359
From: Jay Fraser
Date: Wed, 02 Apr 2003 19:00
104 lines
4833 bytes

      That requirement does keep coming up.




Yeah, me too.There used to be an applications (MS Word?) that would allow you to set a tab to the right (outside) of the right margin. Was great for situations like this.

Roy, this script is one I used on single line paragraphs (specifically, phone directories.) I wanted the tab to always be longer than a certain measurement. I.e., if the tab is less than 2 points, I want to put in a forced line break before the last word of the address.

Since this usually takes a long time, I added a time-stamp at the top & bottom to tell me how long it took.

All of the "set fill color" lines are to help me find errors when I proof the results. I use different colors to tell me what went wrong.

Please let me know if some of this doesn't make sense.

Jay



 
--start time stamp 
tell application "Finder" 
   set myDate to (current date) as text 
   set myTime1 to word -4 of myDate & ":" & word -3 of myDate & " " & word -1 of myDate 
end tell

tell application "InDesign 2.0.1" 
   if (count documents) > 0 then 
      set find preferences to nothing 
      set change preferences to nothing 
      set myDocument to active document 
      set myForced to ASCII character 10 
      set myTab to tab 
      set active spread of active window to parent of page 1 of document 1 
      tell active spread of active window 
         -- checks for "FirstFrame" 
         try 
            set myTextFrame to text frame 1 whose label is "FirstFrame" 
         on error 
            activate 
            display dialog "Can't find 'FirstFrame'. " 
         end try 
      end tell

      tell myDocument 
         set myPink to swatch "C=0 M=100 Y=0 K=0" 
         set myBlue to swatch "C=100 M=0 Y=0 K=0" 
         set myRed to swatch "C=15 M=100 Y=100 K=0" 
         set myGreen to swatch "C=75 M=5 Y=100 K=0" 
         set myDkBlue to swatch "C=100 M=90 Y=10 K=0"

         set myStory to object reference of parent story of myTextFrame 
         repeat with myCounter from 1 to (count of paragraphs of myStory) 
            -- checks if para already has forced line break 
            try 
               set myCheckForced to paragraph myCounter of myStory 
               if myCheckForced does not contain myForced then

                  try 
                     set myAddress to (object reference of word -2 of paragraph myCounter of myStory)

                     try 
                        set myTabIndex to (index of first character of paragraph myCounter of myStory whose contents = myTab) 
                        set myBegTab to horizontal offset of character myTabIndex of myStory 
                        set myEndTab to horizontal offset of character (myTabIndex + 1) of myStory

                        -- fraction is shortest allowable length of tab in pica 
                        if (myBegTab + (2 / 12)) is greater than myEndTab then 
                           set contents of insertion point 1 of myAddress to myForced 
                        end if 
                     on error 
                        set fill color of text of paragraph myCounter of myStory to myRed -- error setting myTabIndex 
                     end try

                  on error 
                     set fill color of text of paragraph myCounter of myStory to myPink -- error setting myAddress 
                  end try

               end if

            on error 
               set fill color of text of paragraph myCounter of myStory to myRed -- error setting myCheckForced 
            end try

         end repeat

      end tell 
   else 
      activate 
      display dialog "Please open a document and try again." 
   end if 
end tell

--end time stamp 
tell application "Finder" 
   set myDate to (current date) as text 
   set myTime2 to word -4 of myDate & ":" & word -3 of myDate & " " & word -1 of myDate 
end tell 
tell application "InDesign 2.0.1" 
   activate 
   display dialog "Start time is:  " & myTime1 & return & "End time is:   " & myTime2 
end tell  
Technical Details
Message-ID: <1de88de4.4@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de88de4.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,8281d9502f387775
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-04-02 11:08:06 PST
From: "Jay Fraser" <jayfraser@yahoo.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: AS Set crieria for new line......
Message-ID: <1de88de4.4@WebX.la2eafNXanI>
Date: Wed, 2 Apr 2003 11:00:42 -0800
References: <1de88de4.-1@WebX.la2eafNXanI>
Lines: 120
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit