B&R function in ST doesnt return Structure or array

xtheking

Member
Join Date
Apr 2019
Location
Berlin
Posts
2
Hi all

I am currently working with an B&R controller using structured text. I have some code, that has previously worked with CODESYS, but when I use exactly the same code in B&R, it gives me this error "Function '....' returns array, string or structure" (Error code 1210). It seems to me that Function in B&R can only return basic data type. But when I read the Help document of Automation Studio, it says that "The function supports return values of the basic types, data types derived from the basic types, enumerations, structures, arrays and string types" . This confuses me.
Do you have any ideas how I could work around this problem?
Thanks
 
Can you post the code? I can see if I can recreate it in my Automation Studio.

You may need to change the function to output to a reference or pointer.
 
Hi Seth, thank you for replying.

The following is an example from B&R documentation

(.typ file)
TYPE
McPointType : STRUCT
X : LREAL;
Y : LREAL;
Z : LREAL;
END_STRUCT;
END_TYPE

(.fun file)
FUNCTION P : McPointType
VAR_INPUT
X : LREAL;
Y : LREAL;
Z : LREAL;
END_VAR
END_FUNCTION

(.st file)
FUNCTION P
P.X := X;
P.Y := Y;
P.Z := Z;
END_FUNCTION

btw this function should be in a library, so I can reuse it.
 

Similar Topics

Im trying to create a level indicator for water Tank i have used the ADD function while the pump is on and level increasing everything works...
Replies
18
Views
182
Good morning crew! Ok my logic works but I am missing something. When the start button is pushed it should like the red light for 4sec then shut...
Replies
13
Views
352
Please see attached file. I need this program in Function Block form but I am totally lost on this. Any help would be appreciated. Thanks!
Replies
8
Views
260
The idea here is to provide for a brief rapid influx of message codes while preventing sequentially repeating the same message. i.e. if two...
Replies
23
Views
536
Howdy, I am currently struggling with an array of values that I want to re-arrange in a programmatic way. My program is a mix of ladder and STX...
Replies
6
Views
366
Back
Top Bottom