taking characters as text produces list?

I have a question… why is this creating a list?

“e,m,a,i,l,@,a,o,l,.,c,o,m”

set email_addr to (characters ((offset of “(” in y) + 1) thru ((offset of “)” in y) - 1)) of y as text

?

It’s not actually a list, Patrick. It’s a string containing loads of commas. :wink: A true list looks more like this: {“e”, “m”, “a”, “i”, “l”, “@”, “a”, “o”, “l”, “.”, “c”, “o”, “m”}

There are a few things you can do to avoid getting unexpected results like those above:

  1. When you are using text item delimiters, make sure they’re finally set back to their initial value: {“”} (That’s a list containing an empty string). Your TIDs must have been set to “,” or {“,”}.

  2. Instead of using ‘characters’ (which creates a list that needs to be coerced back to a string - the nature of which will depend on the current value of AppleScript’s text item delimiters), use ‘text’ for this particular type of job. That way, even if the TIDs are set to something completely whacky, your text won’t be affected by them (and your script will execute faster - because it’s not carrying out unnecessary coercions):

set email_addr to text ((offset of "(" in y) + 1) thru ((offset of ")" in y) - 1) of y
  1. Check out the AppleScript Language Guide (ASLG) at http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/index.html. While it’s beginning to show its age, much of the content is still relevant. It’s where many of us started (and where quite a few return from time to time). Try to familiarise yourself with any sections relevant to what you’re currently attempting. (I still do.) :slight_smile: