2. Program a Variable

Playback Speed:
Language:
Transcript

In this video, you will connect your Slides presentation to the script editor.

This makes it possible to program the code that changes how the application works.

To start, add 4 more slides to your presentation.

Your code will count how many slides there are and make a progress bar of the correct length -- in this case, 5 slides Next, open the script editor...

And name your project.

In these lessons, you will program all your code within the my function.

Inside the function, you will program a variable.

In this case, the variable will store the values that connect your code to your presentation.

You will use many variables to create your progress bar.

Now, place your cursor on the line after the open bracket.

Then, declare a variable called slides.

Type: "V-A-R slides" To get the contents of your presentation, type "equals" then, "slides app".

Make sure the capitalization and spacing exactly match what you see on screen.

Then, type a period to open the autocomplete menu.

From the menu, select get active presentation.

Then, add an open parenthesis.

Type another period, and select get slides.

Then, add an open parenthesis.

Your code now reads: “Create a variable called slides.”

And, in that variable, “store all the slides in the current presentation.”

Save and run your program.

When your code runs, it accesses information from your slides.

To ensure your privacy is protected, you must give your permission before the script accesses a file from your Google account.

Depending on your privacy settings, you also may need to authorize Apps Script to access your slides.

Use advanced settings to run your program.

Great! This program runs without errors.

But sometimes your script will encounter a problem, and an error message will appear.

Don’t worry, even the most experienced developers make mistakes writing code.

Look at this example error message.

It says there is a “type error.”

Forgetting to capitalize something is a very common programming mistake.

In this example, capitalizing the “S” should fix the error.

Great!

At this point, your presentation is still blank.

But in the next video, you add shapes to your progress bar.

Instructions

  1. Add four more slides to your presentation.
  2. Open the script editor, and name your project.
  3. Create a variable to store the presentation.
  4. Save and run the program.
  5. Troubleshoot any error messages.