Function calling
phateee
✭
in RobotStudio
Hello, I am a beginner in programming.I try to make procedure with parametr VAR or INOUT and compiler write me error. I think, that calling procedure with VAR or INOUT is something as pointer in language C/C++. For example:
MODULE A PROC routine(VAR num u)
ENDMODULEAnd compiler write: Argument error(124): Argument for 'VAR' parameter x is not variable reference or is read only
Thank you for your advice ...
ENDPROC
PROC main()
VAR num x;
routine(x);
ENDPROC
ENDMODULEAnd compiler write: Argument error(124): Argument for 'VAR' parameter x is not variable reference or is read only
0
Comments
-
Try this instead:
[CODE]MODULE A
PROC routine(INOUT num u)
u:=2*u;
ENDPROC
PROC main()
VAR num x:=1;
TPWrite "Before routine: x = "Num:=x;
routine x;
TPWrite "After routine: x = "Num:=x;
ENDPROC
ENDMODULE[/CODE]
You can see the result in the Operator panel below:
Henrik Berlin
ABB0 -
The RAPID Overview manual contains a description of INOUT, see
http://www.scribd.com/doc/71173119/Rapid-Overview-Manual#page=112
Henrik Berlin
ABB0 -
The reason you received the above message is because "routine(x)" implies a functin with a return value - the correct use of your format isx:=routine(x); where routine is defined as a funtion with a return value.FUNC num routine(num u)
RETURN 2*u;
ENDFUNCThe instruction call syntax when passing variables or parameters is "routine x;" without ()functin call syntax is "num:=routine(num);". with ()Whenever you use the parentheses () RAPID interprets it as passing parameters to a function that will return a value.To understand the difference please read the Introduction to RAPID section"RAPID instructions and functions"
A RAPID function is similar to an instruction but returns a value
Since the function returns a value, the result of the function can be assigned to a variable. The arguments in a function call are written inside parenthesis and are separated with commas.An instruction call looks like a procedure call with the instruction name followed by argument values not enclosed in parnthesis.Hope this helps...Thomas H. Johnston
PACs Application Engineer0
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