Hello, how to set a return value for a function (not a function block) Code-Type: ST. Signatur: Returntype: LREAL Code: dwTemp := SHL(TO_DWORD(wHigh), 16) + wLow; RETURN TO_LREAL(dwTemp); is not working. I get an Error, want a “;” after RETURN statement I searched in the internet for a long time, but have found nothing.
That’s a great question - I tried exactly the same thing at first, until I learned that the RETURN statement in ST doesn’t do the same thing as it does in C/C++. In ST, the RETURN statement simply returns to the calling POU at that point, and in ST this statement doesn’t take any parameters. To return a value from a function in ST, simply assign a value to the name of the function. So, if your function is called MyFunc, the statement would be: MyFunc := TO_LREAL(dwTemp); I hope this helps.