Teacher Tech blog with Alice Keeler

Paperless Is Not a Pedagogy

Alice Keeler

script.new TRY IT

Script.new
script.new TRY IT
script.new

Try Coding Google Apps Script

You can code Google Apps. Google Docs, Sheets, Slides, Forms, etc… (Currently Google new Google Sites you can not).

Like the other Google Apps products you can use dot new to quickly make a new file of the product. Once you’re in the code editor you will see a function defaulted to being named myFunction(). Your code goes BETWEEN the curly braces.

WHAT APP ARE YOU USING?

Your first line of code is what Google App are you using? Capitalization matters so pay attention!

DocumentApp
SpreadsheetApp
FormApp
SlidesApp
CalendarApp
GmailApp

Press Period

After typing the app you are using, press period. This gives you a multiple choice list of things you can do with that app. Read the list!

Try Create

Since we are in the script editor of an unbound script there is no active document. You can open by ID or open by URL to reference a Docs, Sheets, Slides that you are wanting to interact with.

The easiest one to get started with is .create();

Create a new Google Doc

Semicolon

Important coding rule. Each line of code ends in a semicolon (;).

Text Strings

Some coding jargon is the word string. Which just means words. Think of when you were in Kindergarten and you made a bead necklace with beads that had letters on them. You put the beads on the STRING to make your name for your necklace. A STRING of letters to make a word. So anytime you have a text string (string of characters) you want to put SINGLE QUOTES around it.

Text strings have single quotes on them.

Adding a text string in the parenthesis creates your Google Doc with that name rather than “Untitled Document.” All Google Apps are created in Google Drive. Once you run the code you can find the document in Google Drive.

Save and Run

You will click the save icon in the toolbar and if you have not already named your code it will prompt you to name it.

The sideways triangle is the run icon. Click on this to run the code. You will see a scary authorization screen telling you that no one at Google has reviewed the code. Obviously they have not, you just wrote it! It’s actually an ugly process to get your code submitted to Google and approved so just get used to the warning screen saying that the code has not been reviewed by Google.

Click on “Advanced” and click on “unsafe.” You just coded it yourself, so you know it was not made by a bad person trying to hack you. It is safe.

Click on advanced and unsafe

Check Your Google Drive

There is a document in there!!!

The For Loop

Alice… it would have been way faster to just use docs.new.

Yes… but what fun is that 🙂 YOU CODED THIS! But I hear you, this was just a start on showing you that you can code.

A loop is something that repeats. This is why we code, so we do not have to do the same thing over and over and over again. Let’s make a LOT of Google Docs all at once.

for(var i=0; i<10; i++){}

You do not need to memorize this. You can easily Google Search JavaScript loop and get this code. But, why not make a Google Keep note (keep.new) that contains the for loop.

Notice the curly braces. This is where the code that repeats goes. Now my code will create TEN Google Docs that are named El Chupacabra.

This is a start! You can code!! In the script editor you can use the Help menu to find Tutorials.

© 2024 All Rights Reserved.

💥 FREE OTIS WORKSHOP

Join Alice Keeler, Thursday Mar 28th or register to gain access to the recording.
Create a free OTIS account.

Join Alice Keeler for this session for a way to create dynamic and interactive digital lessons. The Desmos platform is completely free and allows for any topic to be created or customized.

Exit this pop up by pressing escape or clicking anywhere off the pop up.