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
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings