Get Pi With Google Apps Script

Published on April 8, 2022

In this tutorial, you will learn how to use Google Apps Script to get 12,500 digits of pi in your MIT App Inventor application. Before you read this, I suggest you to learn how to deploy a Google Apps Script web app and to play around with Google Apps Script a bit.

🏷️ Tags: #api, #json, #tutorials-and-guides, #google, #apps-script

Step 1. Setup your MIT App Inventor project.

  1. Create a new project, give it a suitable name.

  2. In your project, add a Button (User Interface), a Label (User Interface), a VerticalScrollArrangement (Layout) and a Web (Connectivity).

  3. Set the height and width of the VerticalScrollArrangement to fill parent.

  4. Set the text of the Label to nothing, and set the text of the Button to "Get 12,500 digits of pi". This means that we can now scroll the label text.

  5. Place the Label in the VerticalScrollArrangement so that it contains the Label, and the Button above the VerticalScrollArrangement. Final preview on the right/below.

Step 2. Setup your Google Apps Script.

  1. Create a new Google Apps Script project.

  2. Download the JavaScript file in the Downloads section. Open it with Notepad or any code editor, and copy the whole thing.

  3. Replace the default code in Google Apps Script with the code that you copied.

  4. Save it, and deploy the web app. For instructions for how to deploy a web app, read this.

  5. Copy the deployment URL, and open a new tab in your browser. Paste the URL, and "Enter" on your keyboard. You should see a full screen of numbers. Perfect!

  6. Head back to MIT App Inventor.

Step 3. App Inventor blocks.

All done for you, you just need to change the global url variable.

πŸ“Ή Video

screen-capture (2).mp4

Acknowledgements

I would like to thank Peter Shepherd for his wonderful JavaScript tutorial here. Without it, this tutorial cannot exist!