By the way: what is the "standard text item delimiter" of AS?

Hi Forum,

Mabe a simple question: I got stuck in a script where I use to switch text item delimiters. after I stopped the script once manually, I guess to have a problem because of wrong delimiter definitions.
So I think it would be clever to reset this. But How?

thnx for all suggestions

demski

The default delimiter is “”

The standard sytax is


set theDefault to Applescript's text item delimiters--Stores default delimiter 
set Applescript's text item delimiters to ","--example for comma
--code here 
set Applescript's text item delimiters to theDefault--Replace the default delimiter

but I’ve gotten lazy and I usually just


set Applescript's text item delimiters to ","--example for comma
--code here 
set Applescript's text item delimiters to ""--set to default delimiter

SC

THNX alot!

Just to be completely accurate and because it’s one of my pet peeves, the standard text item delimiters is a single item list, {“”}. Notice that it is “delimiters”, plural. I think I whined about this before and someone posted a reply that Apple originally intended us to be able to use the delimiters as a list but never implemented it.

set x to class of AppleScript's text item delimiters
display dialog "The class of Applescript's text item delimiters is " & x
(*************************************)

set this_string to "abab,cdcd-fgfg"

set old_delimits to AppleScript's text item delimiters  -- Save the original delimiters
set AppleScript's text item delimiters to {",", "-"}

set parse_text to text items of this_string

set AppleScript's text item delimiters to old_delimits -- Restore the original delimiters

FWIW, that’s also my take on the situation. :slight_smile:

Incidentally, if anyone wants to check this, all they have to do is quit Script Editor (if already open) and then relaunch it. (This makes sure that AppleScript’s text item delimiters are reset to their initial value.) Then run this snippet:

text item delimiters
--> {""}

again, thanks for the hints!

I appreciate Your knowledge!

regards, demski