Before moving to Function library, let’s understand what is a Function?
Function: As a definition, Function is nothing but a set of statements(code) combined to cover a particular functionality. Function are used for reusability.Let’s understand with an example.
Consider 2 scenarios.
First: We need to login into gmail and count the no. of emails in the inbox and then log out.
Second: We need to login into gmail and delete the first email and then log out.
As we can see that for both the scenarios ‘Login’ and ‘Log out’ functionalities are common. In both the scenarios, we have to perform login and logout.What can we do? So,we have to write the code only once, not 2 times and same code we can use for both the scenarios.
As a solution, we will write this common lines of code into a function.
How to make this function accessible to all the scripts or the users who are going to use the same Functionality?
For making it accessible to all, We will keep this function at a common place and that common place will be our Function Library.
Function Library: As we have book libraries, and anybody who wants to read the book can go to the book library and read the book whichever he/she wants. In the same way, we keep our function in a file called Function Library.
We just need to attach that library to our Action script and we can call the desired function stored into the function library.
How to create a Function Library?
Go to ‘File menu –> New –> Function Library’
Write your function and save it at any desired location. Function library can have the extension .qfl and .vbs.