 Howdy guys, Andy Pixel here. And in this next set of videos, it might take a couple of videos to explain all this, but what I want to do is I want to explain how functions work inside of Vex. So you can actually declare your own custom functions. That way you can reuse code over and over again. You know if you've been following the series or if you've looked at a lot of other people's Vex code, you don't really see the functions being used all that often. Now this is a great way to start to reuse code and what we're going to do throughout these next set of videos in this series is we are going to implement all the, well not all of the easing functions, but the more popular easing functions like linear and ease in, ease out, and ease in and out. All right, so we'll get all those basics out of the way, but really the point of this is to show you how we can utilize functions inside of Vex. Okay, so let's dive in. So what I'm going to do is create a new geometry node here. Let me hide the previous one here and I'm just going to call this easing video. All right, I'm going to dive inside and delete that file node. All right, so the first thing that I want to do is drop down a wrangle node. All right, I'm just going to select the attribute wrangle node and then just select the run over detail. So we're just going to run this once because this particular node is going to generate all the points. So we'll just call this the easing functions like so. Okay, and what I want to do inside of here is just kind of get a basic understanding of what we can do with these functions. Okay, so let's go and process, you know, just a very, very basic function. So when you start working with functions inside of Vex, what we need to do is we need to declare all the functions first. All right, so I'm going to say functions start here, okay, and then just close that out. So all your functions need to be declared at the beginning of your Vex expression. So best way to do this is hit alt E on the keyboard to bring up the code editor here. It just makes it a little easier to edit. And so what I want to do is create a very simple function. All right, so let's, let's start with a function that doesn't return anything. So what I'm going to do is I'm going to type out void, and we'll call this say something, you know, you see that a lot in code. All right, we'll take in a string. So that's an argument. So we're going to take in some sort of string and then we're going to print it to the console, basically. So this string will just be a message like so. And this is very similar to what we do inside of C sharp and C and Python and mel. I mean, they all kind of follow the same sort of structure. All right, we have this void statement saying we're not returning anything with the name of the function. And then we have our arguments. All right, and then you can have, you know, lots of arguments, you can say int a number or a integer. How about that? And float a float or vector a vector like so. And you can utilize all of that data that's being passed into this function. All right, so this is a great way to kind of modularize your code. You just reuse your code over and over again. All right, so in this case, all I need to do is then do a print f because in vex is how we print the Houdini consoles that print f will print that message. And maybe we'll add something to the beginning, we'll say message is, and we'll do the colon there. We'll do a plus to concatenate it. And there we go. So we have our first function, like so. All right, so what we need to do now is we need a way to actually call this. All right, so remember, we declare our functions first. And then what we do is we put all of our actual code that we're going to going to utilize these functions inside of another block. So I like to use these comments to kind of block things out. And then I usually do something like this, I say code or something like that, custom code. There we go. All right, so what we're going to do is we're going to then say, say something like so. And send in a message. So we can just send in a string, we'll say hello, Houdini, and vex exclamation mark. And now if I were to hit apply, and accept, you can see that in the Houdini console, we get this message is hello, Houdini, and vex. Well, all right, so what we're doing is we're actually calling this function. Okay, so hopefully you can start to see how powerful this is. All right, so let's say we want to create a function that adds two values together is another very popular test function when you're learning how to program. All right, so let's create a function that actually returns a value for us. All right, and this value is going to be a float. And we're going to say add numbers. And what we're going to do is we're going to take in two numbers and they're going to be floats. All right, so we'll say float num a, and then we'll say float num b. Now inside of vex, side effects is made it so that you can actually declare multiple arguments here just by using that comma. So instead of doing it was supposed to be semi colon float num b. All right. But what we can do is we can just put a comma down and say num b just like that. All right, so that way we don't put the type twice. So now we have two arguments. All right, but if you want to add another type, we'd have to put in a semi colon like so and then we'll say something like vector my vex, like so. That's how you would add another argument there. Okay, but we just want to basically add two floats together. Okay, so what we need to do is we need to say return num a plus num b. And that will actually add those two numbers together for us. So let's try this out. So let's do add number. And that's actually stored. So we're going to say float sum is equal to add numbers. And we'll send in something like two and five. All right, and let's just see what that is. So we'll do a print f. We'll say sum or let's do something like this sum is we'll say plus some like so semi colon. There we go. And we'll hit apply. And you can see that we are getting an error. And that's because we need to actually convert our sum to a string. All right. And now what we can do is instead of doing this concatenation like that, because this is not a string, what we can do is we can actually add an argument to this particular string right here by using the percentage g and lowercase g, and then comma, and then the sum and hit apply, you can see that the sum is now seven. So let's clear that. Let's close this. Let's actually make this a new line as well. Like so and hit apply. There we go. Sum is seven. Perfect. So let's try that out. So let's do five and five. Now we get some as 10 on a new line. Cool. So that is the basics of using functions inside of vex. Okay, so I think I'm going to close out this video here. And in the next video, what we're going to do is start implementing all of our easing functions. And then by the end of this little series of videos, we will actually create an HDA that will just allow you to go and select the different easing functions. Okay. Thanks so much.