Hello, this is Kevin. In a previous lesson, we discovered an intrinsic function by the name of current-date. Today, we're going to look at six different types. During this lesson, you'll be able to describe COBOL intrinsic functions, list six types of intrinsic functions, invoke an intrinsic function, and explain how the "ALL" subscript is used with intrinsic functions as well. What is an intrinsic function? Several programming languages, such as C, C++, and Java have built-in functions, in COBOL, they are called intrinsic functions. Webster and Oxford Dictionaries define "intrinsic" as natural, essential, belonging to, and "function" as perform or execute a specific action. Because intrinsic is natural, we do not code it in the data division. There are six classifications for intrinsic functions; calendar functions, keeping track of the dates, character functions, mathematical functions, statistical functions, financial functions, and trigonometric functions. How do we use intrinsic functions? The general format is first the word function, second, the function name, and third, there's going to be zero, one, or many arguments, in other words, the arguments are optional. There are three steps with intrinsic functions, you "function" and pass parameters, the function performs a mathematical or character or logical operation, manipulating strings, dates, and numbers, the function returns derived value(s) of strings or numbers to the program. Now, let's look at the bottom of your screen as we're looking there, after where it says "procedure division", we're going to take a little journey from left to right. First, there is the compute statement, second, the function name of either mean or median, and third, the arguments which are Salary 1, Salary 2, and Salary 3. Now, there's two directions, two ways that an intrinsic function works: left to right and right to left. With this example on the screen, we're going to go from right to left. Underneath where it says "procedure division", COBOL will begin with the three salaries, move to the left and find the intrinsic functions, mean and median, then cross the word function to complete and store the numeric results at average salary and median salary. With the second method, we're going to go from left to right, and this is very small down at the bottom very quick. In this example, the current date function moves eight characters of the date from the left to the right to a working storage field named A-date. Now we need to be aware that there are some coding rules for the intrinsic function. Number 1, we need to define the non-literal data items that you use as arguments in the Data Division, figurative constants are not allowed as arguments. Secondly, you can nest arithmetic expressions as arguments. You can pause for a moment to see an example. The example is Compute A equal to function mean, and then in parentheses, A plus, and then inside of parentheses again, C divided by D. Thirdly, a function that returns a number value can be used only in an arithmetic expression or as the source of a MOVE statement. Then number 4, you can reference all elements of a table as function arguments using the ALL subscript, and we'll see an example of that in a moment. What are function identifiers? Well, function identifiers are a combination of function plus function name followed by any arguments. At the top of the screen, you'll see arguments x, y, and z. A function identifier represents both the invocation of the function and the data value returned by the function. We can use a function identifier in most places in the Procedure Division where a data item that has attributes of the returned value can be used. Function itself is a reserved word, but most function names are not reserved words except for LENGTH, RANDOM, and SUB. A function identifier represents a value that is of one of these data types: it can be alphanumeric, national, numeric, or integer. A function identifier can be the name of a data item. In this example, again, if we look towards the middle, going up towards the top, notice the working-storage section has fields x, y, z, and one called square-root. The procedure division has two compute statements in it and square-root is used to first invoke a function and to name a data item in the program. Let's look at some more examples. We have two intrinsic function examples right here, the first example copies numeric length to NAME-LENGTH using the LENGTH function, the second simply removes the decimal point and everything to the right of the decimal point so that both INTEGER1 and INTEGER2 are going to be equal to the number 5. The FUNCTION INTEGER-PART guarantees the result will be integers and nothing else. This example demonstrates the power of the ALL subscript. In the procedure division, you can see how ALL provides the ability to process the entire table with a single statement. That is powerful. The ALL subscript can only be used with intrinsic functions. Feel free to take another pause to take this all in. Toys on the top, calculators in the middle, and the procedure division down at the bottom. There are many more intrinsic functions. We've put some of these on the screen so once again, feel free to pause and look at some of the intrinsic functions that are available to us. This lesson got us started on learning about intrinsic functions, like I said, there are many, many more, but what you are walking away with now is we know how to describe COBOL intrinsic functions, we can list the six different kinds of intrinsic functions, the different types, we can invoke an intrinsic function, and we can also use the ALL subscript to help us with intrinsic functions. Hope this lesson was intrinsic to you.