In the previous video, you stored each slide of your presentation in a variable of your function.
In this video, you will program code to add shapes to your presentation using this variable.
To start, press enter to go to the next line in your script editor.
The code you program in this video should still be within the curly braces that hold your function, below the line that declares the slides variable.
Type slides, open bracket, zero, closed bracket.
Slides zero indicates that you are working with the first slide in the presentation.
Computer code often starts counting at zero, rather than one.
Next, type a period to open the autocomplete menu.
Select insert shape.
Choose the option that includes left, top, width, and height.
Insert shape tells the computer application the type, position, and size of the shape.
To select a shape, replace shape type and the comma that follows with Slides app.
Remember to match the code you see on screen exactly.
Then, type a period, and select shape type from the menu.
Type another period to see a list of shape options to choose from.
Choose the shape you would like to use for your progress bar.
Then, type a comma after the shape.
To set the position of the shape, replace the words left and top with the numbers zero and three-hundred-ninety-five.
This will place the shape in the bottom left of the slide.
Then, replace the words width and height with the number ten, typed twice, to set the size of the shape.
Save and run your program.
Now, look at the first slide in your presentation.
Nice job -- your shape is at the bottom of the first slide!
If you don’t see your shape, or you get an error message, that’s okay.
Troubleshoot the solution by looking at the error message and ensuring that your code matches what you see on screen exactly.
Currently, your program places one shape on the first slide, but a progress bar requires a shape representing every slide in the presentation and one shape to be colored in with each slide.
You could program a line of code for every shape, but if you had a long presentation, that would take a lot of code.
For example, if your presentation had ten slides, you would have to program ten lines of code for each slide.
That would be one hundred lines of code, so in the next video, you will program a loop to repeat the code for you.
This will save you lots of time and effort.
Now, it’s your turn: add a shape to the first slide of the presentation, set the position of the shape, save and run your program, and troubleshoot any errors.
1. Introduction to Program a Progress Bar in Google Slides
2. Program a Variable
3. Program a Shape
4. Use a Loop to Draw Multiple Shapes
5. Use a Loop to Add Shapes to Every Slide
6. Program a Conditional Statement
7. Program a Progress Bar in Google Slides Wrap-Up
9. Extensions: Program a Progress Bar