codesys no external access to var_in_out parameter
时间: 2024-01-17 17:05:09 浏览: 21
In CODESYS, the var_in_out parameter is used for passing a variable by reference. By default, var_in_out parameters are not accessible from outside the function or method where they are defined. They can only be accessed and modified within the scope of the function or method itself.
If you want to access the var_in_out parameter from outside, you can use an additional variable and assign the value of the var_in_out parameter to it within the function or method. Then, you can access and modify this additional variable from outside.
Here's an example:
```
FUNCTION ExampleVarInOut VAR_INPUT_OUTPUT
var_in_out: INT;
END_FUNCTION
VAR
externalVar: INT;
END_VAR
externalVar := 0; // Initialize the external variable
ExampleVarInOut(var_in_out := externalVar); // Pass the external variable by reference
// Now, you can access and modify the external variable
externalVar := externalVar + 1;
```
In this example, the var_in_out parameter is accessed and modified indirectly through the external variable.