• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Count of Tab characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Count of Tab characters


  • Subject: Re: Count of Tab characters
  • From: Allen Watson <email@hidden>
  • Date: Mon, 22 Jan 2001 16:37:59 -0800

Sorry, can't help any further just now; swamped!

On or near 1/22/2001 10:03 AM, Bill Planey at email@hidden
observed:

>> tell application "Microsoft Word"
>> set allText to text of document 1 -- The front document
>> end tell
>> set od to AppleScript's text item delimiters -- Save existing state
>> set AppleScript's text item delimiters to tab
>> set temp to text items of allText
>> set AppleScript's text item delimiters to od -- Restore
>> -- We now have a list of text items which were separated by tabs. The list
>> -- will contain one more item than there were tabs, so...
>> set tabCount to (count items of temp) - 1
>> display dialog "There are " & tabCount & " tabs in this document."
>
>
> Hi Allen,
>
> Thanks for this suggestion. It does work --if-- the Word file is
> relatively
> small in size. However, most of the files I'll be working with are about
> 32-50 pages in length, and setting all of the file's text to a variable
> causes a system freeze. I test it over and over, same result.
>
> Then I just tried it on a version of the same test document modified down
> to only the first two pages of the original, and it worked - I don't know
> how many more pages it could have handled.
>
> This got me to thinking - if I could make a counter and have the script
> evaluate just one paragraph at a time, maybe the memory problem/freezing
> would stop. I constructed the following:
>
> tell application "Microsoft Word"
> set ParagraphCount to count of every paragraph of front document
> set tabCount to 0
> set i to 1
> repeat
> if i = ParagraphCount then
> exit repeat
> end if
> set ParaText to text of paragraph i of front document
> set OldDelim to AppleScript's text item delimiters -- Save existing
> state
> set AppleScript's text item delimiters to tab
> set ScannedText to text items of ParaText
> set AppleScript's text item delimiters to OldDelim -- restore delimiters
> set ParaTabs to (count items of ScannedText) - 1
> set tabCount to (tabCount + ParaTabs)
> set i to i + 1
>
> end repeat
> end tell
>
>
> ...and this works for 3 paragraphs then freezes the system. Maybe
> something
> that is inside the repeat loop should be taken out of the loop?
>
> To take another tack entirely, maybe I should just capture the number of
> replacements
> from a search and replace (replace "^t" with "zvx") _if that is possible_
> then
> perform an UNDO on the replacement (or close the file with no save).
>
> What do you think?
>
> Thanks,
>
> Bill Planey
>

--
Peace be with you!
Allen <email@hidden> XNS Name: =Allen Watson
My web page: <http://home.earthlink.net/~allenwatson/>
Scripts for OE and Entourage: <http://homepage.mac.com/allenwatson/>


  • Prev by Date: Re: Delay
  • Next by Date: Re: Toggle shared status of files?
  • Previous by thread: Re: Count of Tab characters
  • Next by thread: Re: Count of Tab characters
  • Index(es):
    • Date
    • Thread