Applescript text item delimiters

Those of you that have become Applescript experts must have the patience of an oyster. You have my admiration.

Anyway, I am so frustrated with this I can’t see straight. I have a list item that contains a string of characters that includes spaces and commas. The commas indicate data item seperators that I want to get into another list. Here is what I do that does not work:


mylist={"aaa", "bbb", "ccc ddd, eee fff ggg,hhh"}
set default to Applescript's text item delimiters
set Applescript's text item delimiters to {","}
set newlist to item 3 of mylist
set Applescript's text item delmiters to default

What I want:

newlist={"ccc ddd", "eee fff ggg", "hhh"}

What I get:

newlist={"ccc","ddd","eee","fff","ggg","hhh"}

Can someone help me get this silly delimiters stuff to work? TIA.

Bzzt! Sorry and never mind. I found a function that someone gave me that does it.

You were very close with your orignal code. I modified it to work:

set mylist to {"aaa", "bbb", "ccc ddd, eee fff ggg,hhh"}
set default to AppleScript's text item delimiters
set AppleScript's text item delimiters to {","}
set newlist to text items of item 3 of mylist
set AppleScript's text item delimiters to default

The main change was:

set newlist to item 3 of mylist

to

set newlist to text items of item 3 of mylist

Hope this helps in the future,
Brad Bumgarner, CTA