In this section we deal with various methods to extract different parts of text from lists and other text and at the end, how to put it all together to make a new text string. This is sort of lengthy, but it is pretty easy to follow,
First, to extract text from a list. Both of these result in the text “Computer”:
set theTextList to {"Apple", "Computer"} as list
last item of theTextList
last text item of theTextList --> both statements yield 'Computer'
And then using the ‘reverse’ keyword:
set theTextList to {"Apple", "Computer", "Inc"} as list
last text item of theTextList --> yields "Inc"
set theTextList to reverse of theTextList --> yields {"Inc", "Computer", "Apple"}
last text item of theTextList --> yields "Apple"
As you can see, the keyword ‘reverse’ changes the order of items in a list.
If we want to extract a specific word:
set theTextString to "Apple Computer, Inc"
set theAppleString to word 1 of theTextString
display dialog theAppleString --> yields "Apple"
If we want to extract a specific paragraph:
set theTextString to "Apple Computer, Inc" & return & "Home of Mac OS X"
set theAppleString to paragraph 2 of theTextString
display dialog theAppleString --> yields "Home of Mac OS X"
Extracting by numerical index:
set theTextString to "Apple Computer"-1 is the index for the last letter of the text string, no matter how long the string is; a lot easier than having to determine how long the string is every time!
set computerStringStart to offset of "Computer" in theTextString
display dialog computerStringStart --> yields 7: position of first letter in the word 'Computer'
set computerText to (text computerStringStart thru -1 of theTextString)
display dialog computerText --> yields 'Computer'
The same as saying:
set computerText to (text 7 thru -1 of theTextString)
Of course, if we wanted to, we could say:
'set computerText to (text 7 thru 14 of theTextString)' but why?
set theTextString to "Apple Computer"
set theAppleString to text 7 thru -2 of theTextString
display dialog theAppleString --> yields 'Compute'-2 gets the numeric index of the letter in 'Computer' that is 2 from the end.
set theTextString to "Apple Computer, Inc"
set theAppleString to text 1 thru -1 of theTextString
display dialog theAppleString --> yields: "Apple Computer, Inc"
set theTextString to "Apple Computer, Inc"
set theAppleString to (words 1 thru -1 of theTextString) as text
display dialog theAppleString --> yields "AppleComputerInc"
set AppleScript's text item delimiters to ","
set theTextString to "Apple Computer, Inc"
set theAppleString to (text items 1 thru -2 of theTextString) as text
display dialog theAppleString --> yields "Apple Computer"
The following would give the same result:
set AppleScript's text item delimiters to ","
set theTextString to "Apple Computer, Inc"
set theAppleString to (text item 1 of theTextString) as text
display dialog theAppleString
Why? Because with ‘set AppleScript’s text item delimiters to “,”‘ , what is found before a comma is a text item and what is after a comma is another text item – this can be very useful.
Look at this:
set AppleScript's text item delimiters to " "
set theTextString to "Apple Computer, Inc"
set theAppleString to (text item 1 of theTextString) as text
display dialog theAppleString --> this yields "Apple", because the space determines the value of text items.
set AppleScript's text item delimiters to " "
set theTextString to "Apple Computer, Inc"
set theAppleString to (text item 2 of theTextString) as text
display dialog theAppleString --> this yields "Computer,", because the space determines the value of text items.
This illustrates how to concatenate some text to display a dialog:
set AppleScript's text item delimiters to " "
set theTextString to "Apple Computer, Inc"
set theAppleString to (text item 1 of theTextString) as text
–> the result is “Apple”, because the space determines the value of text items.
set theComputerString to (text 1 thru -2 of text item 2 of theTextString) as text
–> the result is “Computer”, because the space determines the value of text items and ‘text 1 thru -2′ eliminates the comma.
Now we can put it all together:
set dialogString to "Too bad all " & theComputerString & "'s aren't " & theAppleString & "s!"
display dialog dialogString with icon note buttons {"No Doubt"} default button {"No Doubt"} giving up after 5
Contact me if you have any questions or comments at: hyperscripter@gmail.com or http://twitter.com/hyperscripter or to subscribe, click the By Email link at the top of the page.

















I do believe all the concepts you’ve introduced to your post. They are very convincing and can certainly work. Nonetheless, the posts are very quick for beginners. May you please lengthen them a bit from next time? Thanks for the post.
I am personally really fan of your respective blog…will get solved adequately asap. I’m really happy in addition to your text abilties and also together with the blueprint on your own web log. Is that this a paid masquerade or have you personalize it your own? Anyway sustain the beneficial top quality text, it’s uncommon to work out an exquisite blog of this nature the nowadays..
Somebody necessarily help to create strictly content I’d form. It is the truly initial time I frequented your web site page website consequently far? I astonished making use of research you fabricated to create this approach certain submit magnificent. Very good procedure!
Thanks, You haven’t purported to achieve this, however I believe you have got was able to express the mind-set that lots of persons are in.
The sense of planning to assist, however not figuring out how and the place, are some things a variety of us already went through a.
Definitely, exactly what a grand weblog and instructive reviews, I undoubtedly may bookmark your specific website.All the Best!
I d been very glad to find this internet site.I really wanted to express my thanks you for this cool read!! I definitely enjoying every portion of it but i have you ever gigs to looking for new stuff from you post.
My hope is the idea that some constituents of our community may possibly be interested in submitting their scholarly get a job with possible presentation along at the conference.
I had been very happy to locate this site.I wanted to express my thanks you for this cool read!! I finaly enjoying every amount of it and that i have you bookmarked to looking for new stuff from you post.
My hope is because some constituents of our community will be curious about shared their scholarly get a job with possible presentation for the conference.
My hope is the idea that some participants in our community may possibly be curious about shared their activity styling possible presentation along at the conference.
Thanks, You probably haven’t meant to achieve this, however I believe you have managed to express the mind-set that lots of individuals are currently in.
Happy to get visiting your blog again, the doll has been weeks most likely for me. Well, this is actually the story that I’ve been waited for so long.
My hope is the idea that some members of our community will probably be interested in shared their scholarly styling possible presentation at the conference.
I received some great info here. I believe if a greater number of people thought about it like this, they’d have got a better time receive the hang ofing the issue.
My hope is because some members of our community will be interested in promoved their activity rendering possible presentation at the conference.
Entrusting our online bank your spondulicks, we think the risks. We assume that the bank hastily disappears
from the buy, and the moneyed forfeited. Is this possible? Certainly not, because the accumulated savings in
pecuniary institutions of this kredyt dla studentastrain are subject to a mandatory approach of guaranteeing the Bank Promise Fund. They trade the but crumble as stationary banks with alone entire distress (or facility) – lack of access to facilities. Today, Internet banking is offered timber in our banks. Any large-hearted financial institution has in its offer the adeptness to reinforce a bank account via the Internet. The advantages of such a overweight bank, and customers time after time settle upon the convenience, access to the account 24 hours a era and significantly decrease prices as a replacement for services notwithstanding the operation of an Internet account. If anyone has concerns in advance the understructure of an online account, they are unfounded. Adherence to the principal security rules when using online banking makes her safety is maintained at a steep level. Cybercriminals are insecure computers and the naive user. Opportunity into accounts materialize merely as a sequel of phishing looking for your account, which defines the locution phishing. So reagujmy not suspicious e-mails from the bank we use.
Hindrance us also remember that access to Internet banking is not so easy.
It protects the multiple stages of authentication. In appendix, log on to the modus operandi requires a purchaser ID
and password. Then, each bargain proceedings sine qua non be approved lex non scripta ‘common law from rub erase, or watchword of the SMS.
Banks use newer and more advisedly pledge, because only depends on our vigilance or our resources intention be one
hundred percent secure.
I am really fan of your blog…will get solved accurately as soon as you can. I’m really satisfied along side your copy skills and also with all the blueprint against your web site. Is that this a rewarded graphics or have you customise it by yourself? Anyway sustain the excellent high quality composing, it’s uncommon to see a wonderful weblog like this 1 today..
Say thanks lots for giving everyone tremendously marvellous risk to learn to read crucial remarks from here. It’s always so splendid plus full of fun for most people personally and my office companions to look one’s web site at a smallest thrice within a 7 days to see through the new stuff you will have. And also, I’m just always happy of the putting guidelines yourself give. Selected 2 pointers inside this post are extremely essentially the most amazing I’ve ever endured
Please, is it possible to PM me and tell me few more thinks about this particularly,