• 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: parsing text / get specific item
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parsing text / get specific item


  • Subject: Re: parsing text / get specific item
  • From: kai <email@hidden>
  • Date: Mon, 7 Mar 2005 04:10:20 +0000


On Sun, 6 Mar 2005 20:33:42 +0100, Christian Vinaa wrote:

just FYI this is how its possible to find an emailaddress in some text as long as the address is alone on a paragraph

tell application "AppleWorks 6"
        set theParas to the paragraphs of front document as list
        set atSign to "@"
        set emailList to {}
        repeat with y in theParas
                set theChars to characters of y as list
                repeat with x in theChars
                        if x as text is atSign then
                                copy y as text to end of emailList
                        end if
                end repeat
        end repeat

get emailList

try
                set emailAddress to item 1 of emailList as text
        end try
end tell


Nice attempt, Christian. You might be able to make it a little shorter by losing one or two coercions ('as list', as text, etc.) (See how many you can remove before the script breaks...)

Of course, since your script is already targeting AppleWorks, it should be possible to filter items - rather than looping through them. For example, the following line (watch for wraps) produces pretty much the same result as the above script:

----------------

tell application "AppleWorks 6" to tell (document 1's paragraphs where it contains "@") to if (count) > 0 then item 1

----------------

- but then I suppose that's part of AppleScript's charm. There's nearly always another way to do it... :-)

---
kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Set bounds of doc window in Acrobat Professional 6.0.2
  • Next by Date: RE: FTP-delete [Re: (no subject)]
  • Previous by thread: Re: parsing text / get specific item
  • Next by thread: noob question
  • Index(es):
    • Date
    • Thread