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.6K RobotStudio
- 399 UpFeed
- 20 Tutorials
- 14 RobotApps
- 301 PowerPacs
- 406 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 336 IRC5
- 67 OmniCore
- 8 RCS (Realistic Controller Simulation)
- 828 RAPID Programming
- 12 AppStudio
- 4 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 107 Collaborative Robots
- 5 Job listings