
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
-
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.5K RobotStudio
- 398 UpFeed
- 19 Tutorials
- 13 RobotApps
- 299 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 324 IRC5
- 63 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 813 RAPID Programming
- 5 AppStudio
- 3 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings