SA0170: Address of an output variable should not be used
Function | Determines code positions where the address of an output variable (VAR_OUTPUT, VAR_IN_OUT) of a function block is used. |
Reason | It is not allowed to use the address of a function block output in the following way:
|
Exception | No error is reported if the output variable is used within the same function block. |
Importance | Medium |
Sample:
Function block FB_Sample:
FUNCTION_BLOCK FB_Sample
VAR_INPUT
nIn : INT;
END_VAR
VAR_OUTPUT
nOut : INT;
END_VAR
VAR
pFB : POINTER TO FB_Sample;
pINT : POINTER TO INT;
END_VARIF pFB <> 0 THEN
pINT := ADR(pFB^.nOut); // => SA0170
END_IF
nOut := nIn;
pINT := ADR(THIS^.nOut); // no error due to internal usage
pINT := ADR(nOut); // no error due to internal usageAccesses within another function block, in this case in the MAIN program:
PROGRAM MAIN
VAR
fbSample : FB_Sample;
pExternal : POINTER TO INT;
refExternal : REFERENCE TO INT;
END_VARpExternal := ADR(fbSample.nOut); // => SA0170
refExternal REF= fbSample.nOut; // => SA0170