Hello everybody,
I have a very basic/beginner question:
When implementing a method, there is a field on the "Add Method" Window called "Return Type" (for BOOL, and other types)...I couldn't find at the Codesys Online Help further information about this and I'm not sure to understand when a method returns, let's say, an assigned Bool type to what variable...how do I assign a bool variable in the method to a return? or what is this exactly for? ...sorry for the dumb question, could someone please show me a simple example of a use case for this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2019-10-09
Originally created by: scott_cunningham
If you only want to return one variable, use the return type. To assign a value, do something like below. If you need to return multiple variables, use VAR_OUTPUT.
Example will return 7 when you call the method.
METHOD MyMethod : INT
VAR
Dummy : INT := 7;
END_VAR
MyMethod := Dummy;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everybody,
I have a very basic/beginner question:
When implementing a method, there is a field on the "Add Method" Window called "Return Type" (for BOOL, and other types)...I couldn't find at the Codesys Online Help further information about this and I'm not sure to understand when a method returns, let's say, an assigned Bool type to what variable...how do I assign a bool variable in the method to a return? or what is this exactly for? ...sorry for the dumb question, could someone please show me a simple example of a use case for this?
Originally created by: scott_cunningham
If you only want to return one variable, use the return type. To assign a value, do something like below. If you need to return multiple variables, use VAR_OUTPUT.
Example will return 7 when you call the method.
METHOD MyMethod : INT
VAR
Dummy : INT := 7;
END_VAR
MyMethod := Dummy;
Thanks!! This was the part I was missing !!