---
title: "Examples of use - Functions"
url: "https://docs.robotiq.ai/en/article/examples-of-use-functions"
language: "en"
last_updated: "2024-07-09T08:23:50.916Z"
---

# Examples of use - Functions

## **Export steps from process to Function**

Now we will provide an example of how to create a new function from part of the process. In this example, we will use the process that we created in the [Examples of Use - Date and Time steps](https://ynvpklnbkvswa87.productfruits.help/en/article/examples-of-use-date-and-time-steps). To do this, we will select all the steps we want to export to a function and click on the "Export to Function" button.

![](https://cdn-assets.productfruits.com/2dc8f6f9-72a6-493f-951b-0970d03746a0)

Now, provide a name for the function and then proceed back in the process to search for that particular function.

![](https://cdn-assets.productfruits.com/3009ca3d-d8ca-41aa-b8c7-85a5471b73c8)

![](https://cdn-assets.productfruits.com/ddd5abf2-3c64-47ef-8258-6aee29c9c359)

Click on "Define Function Step" and add input/output parameters as needed.

![](https://cdn-assets.productfruits.com/6727eb16-25c2-4ad6-91c4-852021cb7ff1)

First, we will add two input parameters: one for the Integer value of the number of days we want to add, and the other a DateTime parameter for the subtract date. 

![](https://cdn-assets.productfruits.com/cc19dd3e-63ea-4989-b895-480815a3b366)

And now add to that two steps parameters instead fixed values.

![](https://cdn-assets.productfruits.com/9bf48fae-5314-4d68-a9db-68c67e78f112)

![](https://cdn-assets.productfruits.com/573ff29f-6fd3-4d50-8d08-4642612fc9a6)

After adding input parameters, we will also include one output parameter for date as a string.

![](https://cdn-assets.productfruits.com/6476df7f-735c-4e82-9866-24cfc16420ae)

Update the value to the output parameter. Save the Function and proceed to create a new process in which we will use this Function.

![](https://cdn-assets.productfruits.com/104adb9d-7a55-4e39-9d0d-ff3577fd1196)

## **Executing Function**

First, we will create a new string variable and pass it as an input parameter to our function. Then, using the Get Current Date Step, we will save the current date to a DateTime variable and pass it to the output function variable.

![](https://cdn-assets.productfruits.com/8eccd21b-7b7a-4055-bea1-57d046cf4066)

![](https://cdn-assets.productfruits.com/c5b08b21-ad7a-481a-a79e-b63fff8dc692)

Now, select the Execute Function Step and fill out the parameters. For the first input parameter, use AddDays and for the other parameters, use variables.

![](https://cdn-assets.productfruits.com/181671a5-9a02-40a3-9401-00308fabaf6f)

After running the process, the output string variable will contain the value from our Function.

## **Create new Function from beginning**

if you want to create a new function from the beginning, simply go to the function menu and click "Create function".

![](https://cdn-assets.productfruits.com/04342d58-43ce-41c4-bfbd-64001e910dc6)

Now everything is the same as already explained.
