Wow, I am about to write the most amazing script but I need one more thing to work: I know it is possible to set a variable to certain letters in a text like:
set jumpString to text -4 through -6 of the folderName
But is is possible to set a variable to text that is between commas or between spaces? Basically what I need to do is to separate an address into address and state and zip. For instance I have:
Emanuels Vineyards, 212 Fairbanks Road, Oakland, CA 94124
Getting the zip is easy: set text to last 4 characters…
State is easy too since it is always characters -7 and -8, but the city and address is tricky since it always is different length. Like I said, can AS recognize commas or spaces? It’s all so amazing. Thank you very much for your help.
If you are confident that the format of the text will be consistent with your example, this might work.
set contact_info to "Emanuels Vineyards, 212 Fairbanks Road, Oakland, CA 94124"
set tids to text item delimiters
try
set text item delimiters to ","
set items_ to text items of contact_info
set text item delimiters to tids
set name_ to item 1 of items_
set street_ to text 2 thru end of item 2 of items_
set city_ to text 2 thru end of item 3 of items_
set text item delimiters to " "
set state_zip to text items of item 4 of items_
set text item delimiters to tids
set state_ to item 2 of state_zip
set zip_ to item 3 of state_zip
on error
set text item delimiters to tids
end try
It works! Amazing! mapquest driving directions with one button from Filemaker. And I even could keep my pop up list with my favorite addresses. You helped me a lot. Thank you.