'Assign value to interface element without previous instantiation of the implementation

I have a STRUCT (DUT) which one element is an interface.

STRUCT myStruct
   element : iInterf;
END_STRUCT

In declaration session, I have to instantiate first (with same implementation) before assign value to this element.

instance : iInterf_implementation := (some initialization values);
myVar : myStruct := ( element := instance );

Is possible to assign value and instantiate an interface element without create another variable?



Solution 1:[1]

Not that I know of. Here's a quote from the CODESYS documentation: CODESYS always treats variables declared with the type of an interface as references. If an interface is essentially a reference, which is essentially a pointer, then you need a variable for the interface to refer/point at.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Guiorgy