Basics of AppleScript

Custom Delimiters To String

Script [6.14.1]:

set myData to {"Nayan", "Seth"}
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to "|"
set myName to myData as string
set AppleScript's text item delimiters to oldDelimiters
get myName

Explanation: The above Script will add custom delimiter that is | in my case.

First I created a list named myData which contains Nayan and Seth.

By default AppleScript’s text item delimiters is "". So I created a variable oldDelimiters which stores default AppleScript’s text item delimiters.

Now I change AppleScript’s text item delimiters to "|". Next I ask AppleScript to create a variable myName which will contain data of myData and store it as String. Just before executing this statement, I changed AppleScript’s text item delimiters. So instead of "", | will be printed between two items of list. Now I change the AppleScript’s text item delimiters to default.

Finally I use get command to print studentData.

Figure 6.14.1

Figure 6.14.1 Adding Custom Delimiters To String

Note: It is a good practice to reset AppleScript’s text item delimiters because if you want to use these delimiters in your script again, you don’t want the custom delimiter to cause issues in your output.