Applescript is a basic coding language that is great for beginners. To start using AppleScript open the “Script Editor” Application on your mac (You cannot use AppleScript on a Windows PC.)

Once you have it open you can make your first program in AppleScript by typing

in the code box. Click the  button to run the code. You should hear your computer beep. If not, make sure your computer isn’t muted.

Variables

A variable is a piece of information that your program stores, for example, the score in a game.

Types of Variables

In most programming languages, there are 4 types of variables:

String

A string is a piece of text. You must enclose your string in quotes like as shown below:

Integer

An integer is a whole number. You do not need to put in quotes.

Float

A float is a number that can have decimals. You do not need to put in quotes.

Array

An array is a list of variables. It can have strings, integers, and floats, It can have multiple types of variables.

Logic

To create logic we use an if statement.

More Commands

Speak

Popup Box

The text must be in quotes because it is a string. You can also make a variable for the string, as shown below.

Remember that the variable name does not need to be in quotes.

Repeat

Popup Box With Text Box

Getting The Answer

This will say your name when you click “OK”

How it Works

We create a variable called x, but instead of making it a string, float, or array, we make it a popup box.

Then we create a variable called yourName and set it to the text returned of x.

Finally, we use the say command to speak yourName.

Adding Custom Buttons

You can add custom buttons to your dialog, by adding the buttons attribute, with an array of strings (The button names).

You can also use a variable for the buttons array:

Comments

Comments are text in you code that your computer will not read. They are there to help you, and others understand the code.

To create a comment in AppleScript, Just type “–” (without the quotes) before your comment.

Making a Simple Game

This game uses many of the topics above. I added comments to the code to help you understand.

Categories: ComputersProgramming

tyler58546

Hi, I’m tyler58546, and I make maps for Minecraft, and Portal 2. I also own a Minecraft Server Called Futuristicraft. I like coding, and making websites.

1 Comment

MAMA'S LITTLE ANGEL KEEPER · May 17, 2018 at 2:30 PM

TYLLLLLLLLLLEEEEEERRRRRRRR . KKKKKKAAAAAAAAAANNNNNNOOOOOOXXXXXXXXX!!!!!!!!!!!! YOU ARE A HOMIE AND I WILL MISS YOU WHEN YOU GO TO HIGH SCHOOL. I HOPE THAT YOU KNOW THAT YOU MADE HTM A BRIGHTER PLACE WHILE YOU WERE HERE. PLEASE CONTINUE TO SHARE YOUR INNER LIGHT WITH EVERYONE!

-NAMASTE

Leave a Reply

Your email address will not be published. Required fields are marked *