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.
Create a new project, give it a suitable name.
In your project, add a Button (User Interface), a Label (User Interface), a VerticalScrollArrangement (Layout) and a Web (Connectivity).
Set the height and width of the VerticalScrollArrangement to fill parent.
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.
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.
Create a new Google Apps Script project.
Download the JavaScript file in the Downloads section. Open it with Notepad or any code editor, and copy the whole thing.
Replace the default code in Google Apps Script with the code that you copied.
Save it, and deploy the web app. For instructions for how to deploy a web app, read this.
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!
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
Acknowledgements
I would like to thank Peter Shepherd for his wonderful JavaScript tutorial here. Without it, this tutorial cannot exist!
Β© Gordon Lu π§ E-mail π¬ Message π Phone call