Using Functions
In this chapter we are going to learn about the Using Functions
Introduction
We can create this program quickly using the Quick Start component
![ib_quickstart_usingfunctions.png](_images/ib_quickstart_usingfunctions.png)
Program Steps
After selecting the (Using Functions) template, we will get the next steps in the Goal Designer
![gd_quickstart_usingfunctions.png](_images/gd_quickstart_usingfunctions.png)
The Steps Tree:
first()
second()
sum(3,5)
sum(1000,2000)
Print fact(5) (New Line)
If novalue() = NULL
Print the NoValue() function doesn't return a value (New Line)
End of IF Statement
function first
Print message from the first function (New Line)
End of Function
function second
Print message from the second function (New Line)
End of Function
function sum x,y
Print x+y (New Line)
End of Function
function fact x
If x = 0
Return 1
Else
Return x*fact(x-1)
End of IF Statement
End of Function
function novalue
End of Function
Creating the Program
To create this program we will use the next components
Call Function
If Statement
Else
Define Function
Print Text
Return
In the begining the Steps Tree is empty
![1.png](_images/160.png)
Call the first() function
![2.png](_images/227.png)
![3.png](_images/320.png)
![4.png](_images/419.png)
Call the Second() function
![5.png](_images/515.png)
![6.png](_images/612.png)
![7.png](_images/712.png)
Call the Sum() function - Send 3,5 as parameters
![8.png](_images/812.png)
![9.png](_images/912.png)
![10.png](_images/1012.png)
Call the Sum() function - Send 1000,2000 as parameters
![11.png](_images/1116.png)
![12.png](_images/1214.png)
![13.png](_images/1313.png)
Call the Fact() function - Send 5 as parameter
![14.png](_images/1411.png)
![15.png](_images/1511.png)
![16.png](_images/1611.png)
Check the output of the NoValue() function
![17.png](_images/178.png)
![18.png](_images/187.png)
![19.png](_images/197.png)
Print a message using the (Print Text) component
![20.png](_images/206.png)
![21.png](_images/2111.png)
![22.png](_images/228.png)
Define the First() function
![23.png](_images/235.png)
![24.png](_images/245.png)
![25.png](_images/255.png)
Print a message from the First() function
![26.png](_images/265.png)
![27.png](_images/274.png)
![28.png](_images/284.png)
Define the Second() function
![29.png](_images/294.png)
![30.png](_images/304.png)
![31.png](_images/3110.png)
Print a message from the Second() function
![32.png](_images/325.png)
![33.png](_images/334.png)
![34.png](_images/344.png)
Define the Sum() function
This function takes x,y as parameters
The function will print the sum of x and y
![35.png](_images/354.png)
![36.png](_images/364.png)
![37.png](_images/374.png)
![38.png](_images/384.png)
![39.png](_images/393.png)
![40.png](_images/403.png)
Define the Fact() function
![41.png](_images/4110.png)
![42.png](_images/424.png)
![43.png](_images/434.png)
![44.png](_images/442.png)
![45.png](_images/452.png)
![46.png](_images/462.png)
![47.png](_images/471.png)
![48.png](_images/481.png)
![49.png](_images/491.png)
![50.png](_images/501.png)
![51.png](_images/516.png)
![52.png](_images/522.png)
![53.png](_images/532.png)
![54.png](_images/542.png)
![55.png](_images/552.png)
Define the NoValue() function
![56.png](_images/562.png)
![57.png](_images/571.png)
Now we have the final Steps Tree in our program
![58.png](_images/581.png)