Felix
Felix

Reputation: 1189

How to assign the value to be returned by a method?

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;

Upvotes: 2

Views: 967

Answers (1)

Jacek Domański
Jacek Domański

Reputation: 640

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 :)

Upvotes: 5

Related Questions