Academy ↓
Hey there stranger!
Spreadsheet Automation 101: Parentheses
About this Tutorial
Video Transcript
0:11 So again, we'll go up to ca extensions app script. We have our app script that we've been working on here and we will work on in a video or two.
0:20 But I wanna show you, I just want to point out all of the parenthesis in the function name. We always have the name of the function, and then two parenthesis, open parenthesis and closed parenthesis.
0:30 These are very, very important. They're almost like a, a parent warmly hugging all of their children. All of these little variables here, like you can have 1, 2, 3, not toe, but two, three.
0:43 You can have ver many variables inside of here. And these parentheses are like a parent. They, they hug their children.
0:50 They're very, very, very important. You must have parentheses here and you must have parentheses are on function names after function names, except almost everything gets a parenthesis except the first one when we're talking about like spreadsheet app, mail app will get to, there's a few other apps that are included in app script that allow us to use functions within them.
1:14 These do not have parentheses. So if we have something like this, let's see the one, let's go back and make sure this does work right?
1:24 But if we use a spreadsheet app and we put parentheses here, let's see if that actually works. And if we, let's see if we get an error, we do get an error.
1:32 And what that error is, is spreadsheet app is not a function line three. And this is telling us something that we might not necessarily groc right away.
1:41 Okay? We can look at line through three and we're like, what is wrong with this? Right? There's spreadsheet app, there's GI active spreadsheet, I got parenthesis on everything.
1:49 And the issue is you got parenthesis on everything. The first one spreadsheet app does not have parenthesis. It's not a function of spreadsheet app, it is spreadsheet app itself.
2:00 Maybe something like this. The one, if we take off parentheses here, we'll have maybe another error. Let's see if it changes that error.
2:13 Nope, actually we don't get an error there. So we don't need, oh wait, we haven't saved it. Okay, <laugh>, we haven't saved it at all.
2:19 In fact, we get the error in app script itself. It's a syntax error, unexpected token. It has a curly bracket line one right here in the file code ees.
2:30 So we look at line one and we're like, well, that curly bracket is correct. Every single function should have a curly bracket.
2:36 And notice here I mentioned earlier that sometimes where the error says it is an error, it's actually just before that.
2:42 And in fact, this is the error, right? The error is not the curly bracket itself, it's the fact that we don't have parentheses.
2:49 So we add parentheses, open parenthesis, close parentheses, and now we save. And now we're able to save, right? We don't get an error inside of app script.
2:58 We don't get an error here in our Google sheet. We now have a functional function with parenthesis. I wanted to point out, well, we're here though.
3:09 That parent inside the parenthesis sometimes does what there is sometimes matters. So if we have like a variable range here and we're trying to get like a one and we are doing get range, range, cuz we can use a variable for that range, we're gonna get an error if we run it from inside of app script.
3:33 Let's see, we'll have to review our permissions. We'll do this again later. I'm not gonna walk through this right now.
3:39 Just get through this. We could probably get an error. Yeah, argument cannot be null. A one notation. So what this is telling us is that actually right here, this line range and range, there's nothing there.
3:56 We don't, it's a variable. A variable must be filled with something. So this doesn't mean that our function is wrong, it means that we're running it from the wrong place.
4:06 So if we put inside the parenthesis here, the one in quotes, a one that gives us the actual value of the variable.
4:16 So now the range, this range is a one and this range is a one. So we get through this, this argument in the, the error by actually adding something that is defined, which is a one, but we do it inside of the parenthesis here.
4:30 Again, we're gonna get deeper into this and how these variables work. And you'll see this multiple times over and over and over again with variables inside the parenthesis without variables inside the parenthesis.
4:39 Sometimes we want 'em, sometimes we don't. Sometimes it's all sorts of things. So check out, like if we use sheet one here and we don't use quotes, it looks pink.
4:50 Not that like brown. So that is going to be a problem. And let's see what we got here. And we got an error.
4:58 And it says error sheet one is not defined perfect because we need inside these parentheses, we need it in quotes.
5:04 Sometimes we need in quotes, sometimes variables don't have quotes. But if we have actually like an actual string that we want, we put that in quotes here just like we did here in with a one in quotes.
5:16 All right, thanks for watching now on two more. I'm so glad you got through all these videos. Bite.
Courses
Spreadsheet Automation 101: Introduction to Pre-course Videos
Breaking Through Errors In Apps Script
Think Like a Programmer: Develop The Mindset of an Apps Script Coder
Tips to Navigating Thousands of Lines of Code In Apps Script
Spreadsheet Automation 101: Functions
Spreadsheet Automation 101: Variables
Spreadsheet Automation 101: Dot Notation
Spreadsheet Automation 101: Camel Case
Spreadsheet Automation 101: Parentheses
Spreadsheet Automation 101 Lesson 1: GetValue - Introduction to SpreadsheetApp
Spreadsheet Automation 101 Lesson 1: Spreadsheet Taxonomy
Spreadsheet Automation 101 Lesson 1: A1 Notation vs Row,Column Syntax
Spreadsheet Automation 101 Lesson 1: getActiveSpreadsheet() vs getActiveSheet()
Spreadsheet Automation 101 Lesson 1: onOpen() Trigger - Custom Menu
This Seems Like Automation
Spreadsheet Automation 101 Lesson 2: Get Values - Introduction
Spreadsheet Automation 101 Lesson 2: Arrays
Spreadsheet Automation 101 Lesson 2: For Loop
Spreadsheet Automation 101 Lesson 2: Bracket Notation
Spreadsheet Automation 101 Lesson 2: Logger.log()
Spreadsheet Automation 101 Lesson 2: If ( ){ } and Checkboxes
Spreadsheet Automation 101 Lesson 2: onEdit() Trigger
Introduction to Spreadsheet Automation 101 Lesson 3
Spreadsheet Automation 101 Lesson 3: MailApp
Spreadsheet Automation 101 Lesson 3: Email Yourself For Loop
Spreadsheet Automation 101 Lesson 3: Send Email Every Week Trigger
Spreadsheet Automation 101 Lesson 3: Email Other People For Loop
Spreadsheet Automation 101 Lesson 4: Access APIs Introduction
Spreadsheet Automation 101 Lesson 4: UrlFetchApp
Spreadsheet Automation 101 Lesson 4: OmdbAPI get ApiKey, get Data in URL
Spreadsheet Automation 101 Lesson 4: OmdbAPI get data in Apps Script
Spreadsheet Automation 101 Lesson 4: JSON (beautifier) and OmdbAPI parameters
Spreadsheet Automation 101 Lesson 4: OmdbAPI Parameter Picker
Automatically Clear Content | Refresh Reuse Recycle Templates
Automate Google Sheets With Zero Experience
Automatically Uncheck A Daily Checklist
Activate A Certain Sheet When Opening a Spreadsheet
Scoping Functions in Apps Script