2

I have a method which I want to be returning a value. The declaration is clear to me. But how do I assign the value to be returned inside the method implementation?

I can only think of creating an output variable and use that to propagate the value to the caller. But that is definitely not how I would expect a return value to work:

METHOD M_MyMethod : BOOL
VAR_OUT
    bReturnVal : BOOL;
END_VAR
// Do some method things here.
// Then assign the return value.
bReturnVal := bWhatever;
Felix
  • 1,066
  • 1
  • 5
  • 22

1 Answers1

5

The solution is simple:

M_MyMethod := bWhatever;

Using VAR_OUT is also usefull, if you need to return more than one value and don't want to create dedicated type :)

Jacek Domański
  • 563
  • 3
  • 7
  • Damn. That was to easy, Thanks. I will however leave the question, just in case someone else strumbles upon this issue. – Felix Jul 11 '22 at 11:23