# Function returns an array

**URL:** <https://tech-community.robotics.abb.com/t/function-returns-an-array/6458>\
**Category:** RobotStudio\
**Created:** [January 19, 2015, 9:30am UTC](https://tech-community.robotics.abb.com/t/function-returns-an-array/6458 "2015-01-19T09:30:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ko414du4](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@ko414du4](https://tech-community.robotics.abb.com/u/ko414du4)\
**Post date:** [January 19, 2015, 9:30am UTC](https://tech-community.robotics.abb.com/t/function-returns-an-array/6458/1 "2015-01-19T09:30:31Z")

</div>

Hello,

I’m trying to create a function that return an array of 4, data type bool. I thought creating a record for this purpose is an overkill. Can anyone help me please? Thank you.

---

<div class="post-metadata">

**Author:** ![Micky](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@Micky](https://tech-community.robotics.abb.com/u/Micky)\
**Post date:** [January 19, 2015, 11:54am UTC](https://tech-community.robotics.abb.com/t/function-returns-an-array/6458/2 "2015-01-19T11:54:02Z")

</div>

Hi,

a function can not return an array but you can use a procedure which returns the modified array.

Please refer also to the following thread “[Return an array of num from a function](http://forums.robotstudio.com/discussion/comment/23376/#Comment_23376http://)”

Example:

proc Example()  
var bool bArray{4};

!Call routine to set the data of the array  
ModifyArray bArray;  
endproc

!Array will be handled as by reference and returns the modfied values  
proc ModifyArray(INOUT bool array{\*}  
!use function DIM to get the size of the handed over array  
for i from 1 to DIM(array,1) do  
array{i}:=…  
endfor  
endproc

/BR  
Micky

---

<div class="post-metadata">

**Author:** ![ko414du4](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@ko414du4](https://tech-community.robotics.abb.com/u/ko414du4)\
**Post date:** [January 19, 2015, 2:57pm UTC](https://tech-community.robotics.abb.com/t/function-returns-an-array/6458/3 "2015-01-19T14:57:03Z")

</div>

> [@Micky](#):
>
> Hi,
> 
> a function can not return an array but you can use a procedure which returns the modified array.
> 
> Please refer also to the following thread “[Return an array of num from a function](http://forums.robotstudio.com/discussion/comment/23376/#Comment_23376http://)”
> 
> Example:
> 
> proc Example()  
> var bool bArray{4};
> 
> !Call routine to set the data of the array  
> ModifyArray bArray;  
> endproc
> 
> !Array will be handled as by reference and returns the modfied values  
> proc ModifyArray(INOUT bool array{\*}  
> !use function DIM to get the size of the handed over array  
> for i from 1 to DIM(array,1) do  
> array{i}:=…  
> endfor  
> endproc
> 
> /BR  
> Micky

Thank you!
