AppleScript

This story is a tutorial within a story. You will read about a fictional event that will teach you about both the AppleScript scripting language and general programming concepts. This is the first in a series of AppleScript tutorials.
Introduction

It is 9am, Monday. I am drinking coffee, enjoying a beautiful spring morning.

A dialog box appears on my iMac. It says, "How you are. I am going talking to you."

I type, "I am fine. However if we are going to talk, I will help you with your English."

Another dialog box appears. "O.K. You help me with English and I will help you with AppleScript."

What is AppleScript?

I am curious. My computer tells me that it will help me with AppleScript. What is AppleScript?

I find some computer books I bought awhile back. One of them is about AppleScript. I wipe the dust off the cover and read the introduction. It says:

AppleScript is an easy-to-use programming language that allows you to:
  • Learn programming concepts that are applicable to programming and other programming languages
  • Automate tasks that you do everyday on your iMac
  • Write programs


Most programming books say that their language is easy to learn. I am skeptical. However as I read, I learn that this language is quite English-like.

I decide to make some notes that will allow me to ask my iMac some questions when we begin teaching each other. Here they are.

AppleScript uses something called classes. It appears that classes are like nouns. AppleScript classes include:
  • Dates
  • Numbers
    • Integers
    • Real numbers
  • Text (also called strings).
  • Lists
  • Records
Classes

I do some more research. I begin by reading about classes. Here are the results of my research.

Classes are like nouns. They are things. Some of AppleScript's classes are:

  • Dates are entries in a calendar. They represent time. For example, July 28, 1923 is a date. Friday, April 30th is also a date.
  • Numbers are a common concept. My paycheck contains numbers. When I way myself I see a number. I don't like it, but it is a number.
  • AppleScript uses two types of numbers: integers and real numbers. At first this sounds mathematical, but we use integers and real numbers every day.
  • Integers are numbers without decimals (numbers following a decimal point). They are counting numbers. For example, a piano has 88 keys.
  • Real numbers contain decimals. Dollar amounts use real numbers. For example, my AppleScript book cost $19.95.
  • Text (strings) is a common thing. Text is characters, words, paragraphs and so on.
  • Lists are interesting. They are a group of things. For example a grocery list is a group of food items that you need to purchase.
  • Records are containers that hold related information. For example, a person's mailing address is a container of related information. It contains a person's name, street address, city or town, state or province, and zip or postal code.


Closing Thoughts

AppleScript and English are both languages. We use them to communicate. Both languages use parts of speech. AppleScript has classes; English has nouns. I am sure as I talk to my iMac I will learn that AppleScript contains other parts of speech.

The following table summarizes the classes discussed in this article.

ClassDefinition
DatesDates are entries in a calendar. They represent time.
NumbersNumbers are integers (whole numbers) or real (decimal values).
TextText (strings) consists of characters, words, paragraphs, etc.
ListsLists are a group of things.
RecordsRecords are containers that hold related information.

By Alan Cohen
Published: 3/24/2004
 
Use the feedback form below to submit your comments.
Your Comments:
Your Name:
Use the form below to email this article to your friends.
Recipient Email Address:
 Separate multiple email addresses by ;
Your Name:
Your Email Address: