Function returns an array
                
                    ko414du4                
                
                     ✭                
            
                        
                
                                    
                                  in RobotStudio             
            
                    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.
                0  
            Best Answer
- 
            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"
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
5 
Answers
- 
            
Thank you!Micky said: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"
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
Micky0 
Categories
- All Categories
 - 5.6K RobotStudio
 - 401 UpFeed
 - 21 Tutorials
 - 15 RobotApps
 - 306 PowerPacs
 - 407 RobotStudio S4
 - 1.8K Developer Tools
 - 250 ScreenMaker
 - 2.9K Robot Controller
 - 363 IRC5
 - 81 OmniCore
 - 8 RCS (Realistic Controller Simulation)
 - 853 RAPID Programming
 - 31 AppStudio
 - 4 RobotStudio AR Viewer
 - 19 Wizard Easy Programming
 - 110 Collaborative Robots
 - 5 Job listings