To start building scripts, you should begin by creating a new folder for them in your Google Drive.  Like all Google Docs, Scripts live in your Drive.  Click the button (if you don’t see the New button, click and then “Experience the New Drive”).

After you click New, hover over More, and see if Scripts have been added to your Apps list. If you don’t see Scripts there, click Connect More Apps

Clip - Connect More Apps.jpg

Type “script” in the search box, and then click for Google Apps Script.

Now when you click  you will see an option under More for Google Apps Script. Click it and you will see the splash screen, as below.

Click “Blank Project”

Now you will see an Untitled Project, with the beginnings of a function in it called “myFunction”.

Inside of the braces, type Logger.log(“Hello, world!”);  It should look like this:

Now, above the function, type

/*

  Insert comment here

*/

This is probably the simplest Google Scripts program you will ever see. There are three elements to it:

  1. Comment - It is a good idea to include a Comment section at the top of every script you write, and also to comment on each function in order to explain how it interacts with the rest of the program. You usually don't need to comment on WHAT any particular line of code does, what you need to focus on is the HOW and WHY.  To create a comment, use the /* symbol at the beginning and then */ at the end.
  2. Defining a function - The default name is myFunction, but you can easily change this. The word 'function' means that you are DEFINING a function rather than CALLING it. Defining a function means that this function will execute a particular sequence of commands, marked off between braces {}.  The parentheses after 'myFunction' are for any parameters (which will be discussed later).
  3. Set of commands in a function - Inside every function there are a series of commands that give that function its purpose. In this particular case, the function is telling the Logger to add a new line, "Hello, world!" To run the function, click Run > myFunction. To see what it does, click View > Logs. You should see your "Hello, world!" line, just after a timestamp.

 

Try changing the message in the Logger, or adding a new line to the Logger and see what happens. Be sure to update the comment and let everyone know this is your first Google Script!