• 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: Capturing parts of text string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Capturing parts of text string


  • Subject: Re: Capturing parts of text string
  • From: kai <email@hidden>
  • Date: Mon, 4 Jul 2005 06:10:48 +0100


On Monday, July 4, 2005, at 05:24 am, Patrick Collins wrote:

using option #1, i get:
Can't get text from word 1 of text 11 thru -1 of "Northbrook, IL 60062"
to word -2 of text 11 thru -1 of "Northbrook, IL 60062" of ", IL 60062".


using option #2, I get:
Can't get text from word 1 of item 2 of {"Northbrook", " IL 60062"} to
word -2 of item 2 of {"Northbrook", " IL 60062"} of " IL 60062".

...  This script is extracting the contents of an html message in
mail.app by:


tell application "Mail" set theseMessages to selection set thisMessage to item 1 of theseMessages set myTexted to (content of thisMessage) as string end tell set myText to myTexted as string


repeat with y in paragraphs of myText
... from there, we get to the part where it uses your routines.. if you
have any ideas why im getting these errors, that would be wonderful to
know... Does it have to do with the fact that Las Vegas was 2 words and
Northbrook is one?

No it doesn't, Patrick - as I hope you'll see from the examples below (in which I've changed the input text to "Northbrook, IL 60062").


Can you tell me if you get the same results as me when running each of these snippets separately (without placing them in your script)?

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

on locationAsList(l)
set o to offset of "," in l
tell l to {text 1 thru (o - 1)} & (text o thru -1)'s {text from word 1 to word -2, word -1}
end locationAsList


set x to "Northbrook, IL 60062"
set {city, state, zip} to locationAsList(x)

--> {"Northbrook", "IL", "60062"}

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

on locationAsList(l)
set d to text item delimiters
set text item delimiters to ","
tell l's text items to set l to {item 1} & item 2's {text from word 1 to word -2, word -1}
set text item delimiters to d
l
end locationAsList


set x to "Northbrook, IL 60062"
set {city, state, zip} to locationAsList(x)

--> {"Northbrook", "IL", "60062"}

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

If the handlers don't run successfully on their own, then we would appear to have some behavioural differences between our machines.

However, if the handlers *do* run without error on your machine, then they are working as (I) expected. That would indicate that they're not getting text such as "Northbrook, IL 60062" from your script. If this is the case, then you'll have to go back to your script and check exactly what is being fed to the handlers. (I can't really second-guess what that might be, since I don't know exactly what the "content of thisMessage" is - or how you're specifically parsing it to get the location data.)

---
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


References: 
 >Re: Capturing parts of text string (From: "Patrick Collins" <email@hidden>)

  • Prev by Date: Re: Capturing parts of text string
  • Next by Date: Re: Capturing parts of text string
  • Previous by thread: Re: Capturing parts of text string
  • Next by thread: Re: Capturing parts of text string
  • Index(es):
    • Date
    • Thread