• 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: Eliminating items from a MS Word list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Eliminating items from a MS Word list


  • Subject: Re: Eliminating items from a MS Word list
  • From: "Marc K. Myers" <email@hidden>
  • Date: Sat, 16 Jun 2001 10:51:07 -0400
  • Organization: [very little]

> From: email@hidden
> Date: Sat, 16 Jun 2001 05:33:35 EDT
> Subject: Re: applescript-users digest, Vol 2 #766 - 16 msgs
> To: email@hidden
>
> >I'm trying to create a script which will take a (very long... probably too
> >long for Applescript's memory buffer) list of items in Microsoft Word,
> >and eliminate those which are shorter than 4 characters or longer than 9.
> Each
> >item is separated by a carriage return, and I'd like to eliminate the
> >carriage returns along with the deleted item, so that I'm left with a neat
> >list with no vertical spaces between items.
>
> Thanks everyone, for your help, and Paul, for the suggestion of Tex-Edit
> Plus. A great program, with awesome Applescript support. MS Word is now
> unneccessary (whew!) Here's a short script which works:
> tell application "Tex-Edit Plus"
> delete (every word in window 1 where (length of it is less than 4))
> end tell
>
> Two problems which I'm having, though, are: 1. I can't seem to figure out how
> to eliminate the carriage returns which go with the deleted words. (The doc
> contains a list of words, each followed by a carriage return - this script
> eliminates the word, but leaves a blank space between the surrounding items
> in the list). 2. This script works on up to a certain length list. Beyond
> that, the script hangs up, I have to force quit Tex-Edit, and Applescript
> gives me a "timed out" error message. Are there any work arounds, or will I
> have to do my lists in smaller chunks?

Timeouts occur when AppleScript doesn't get a response from an
application in a specified period of time. When your script calls TE+
to process a long file it probably takes longer than the default 60
seconds. To get around this, bracket the call to TE+ with "with timeout
of 600 seconds" and "end timeout". This will set the timeout period to
600 seconds.

To eliminate the excess carriage returns, I'd use TE+'s "replace"
command in a loop. Do this after the code that excises the unwanted words:

set chgCnt to 1
repeat until chgCnt = 0
set chgCnt to (replace window 1 looking for return & return [optn-L]
replacing with return)
end repeat

--> Note: replace [optn-L] with the AS continuation character

The replace command returns the count of items replaced, so this will
loop through the text replacing double returns with a single return
until there are no more double returns.

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[6/16/01 10:48:34 AM]


  • Prev by Date: Re: Add scaled
  • Next by Date: Re: Change all labels to 0 if... > help!
  • Previous by thread: Re: Eliminating items from a MS Word list
  • Next by thread: ImageMagick and RGB Colours
  • Index(es):
    • Date
    • Thread