Compilation errors 4061 and 3761 indicate two different misuses of a VAR_IN_OUT parameter. The function block requires a writable caller variable, not a constant or an initialized interface declaration.
Interpret errors 4061 and 3761
| Code | Meaning | Required correction |
|---|---|---|
| 4061 | The VAR_IN_OUT parameter is not connected to a writable variable. |
Pass a variable declared in the calling program's ordinary VAR section. |
| 3761 | A VAR_IN_OUT declaration has been given an initial value. |
Remove the initializer from the interface declaration. |
Separate the function-block interface from caller storage
Keep xLearnNodon3 as VAR_IN_OUT inside the library function block because the block can both read and modify it. In the program that calls the block, declare the connected object as a normal VAR. The caller does not need its own VAR_IN_OUT...END_VAR section for this object.
(* Calling program *)
VAR
xLearnNodon3 : BOOL;
END_VAR
(* Function-block interface, defined by the library *)
VAR_IN_OUT
xLearnNodon3 : BOOL;
END_VAR
Connect a writable variable
- Move the caller-side declaration of
xLearnNodon3into the program's ordinaryVARsection. - Connect that variable to the function block's corresponding
VAR_IN_OUTparameter. Do not connect the literalTRUE, because a literal is not writable storage. - Remove any initializer from the function block's
VAR_IN_OUTdeclaration. - Compile again and confirm that errors 4061 and 3761 are absent.
Verify read/write behavior
Before executing the function block, assign the required value to the caller variable through normal program logic. After the call, inspect the same variable: the function block may have modified it because VAR_IN_OUT provides read and write access to the caller's storage.
FAQ
What does PFC200 compilation error 4061 mean?
Error 4061 means a required VAR_IN_OUT parameter is not connected to writable storage. Connect it to a caller variable declared under VAR.
Why does assigning TRUE cause error 3761?
A VAR_IN_OUT parameter cannot use an initial value, and the literal TRUE cannot serve as writable storage. Remove the initializer and pass a writable Boolean variable.
Should xLearnNodon3 be VAR or VAR_IN_OUT?
Declare xLearnNodon3 as VAR_IN_OUT in the function-block interface and as an ordinary VAR in the calling program.