<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Store different data types in same array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d9a88997af/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d9a88997af/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/d9a88997af/</id><updated>2020-02-27T13:48:09.633000Z</updated><subtitle>Recent posts to Store different data types in same array</subtitle><entry><title>Store different data types in same array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d9a88997af/?limit=25#3ae6" rel="alternate"/><published>2020-02-27T13:48:09.633000Z</published><updated>2020-02-27T13:48:09.633000Z</updated><author><name>fatroshi</name><uri>https://forge.codesys.com/u/fatroshi/</uri></author><id>https://forge.codesys.com9f0444972b6a12961bb142c689e84f46faf09ef4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;strong&gt;dFx&lt;/strong&gt; Thank you for your reply, that could be a solution for the problem but imagine if you had 50 different objects. My goal is to store different data types.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;e.kislov&lt;/strong&gt; Thank you for the link, It helped a lot. But sadly as &lt;strong&gt;SGronchi&lt;/strong&gt; mentioned the array would only store references to them. I will look into dynamic memory allocation and see if I can manage to resolve this.&lt;/p&gt;
&lt;p&gt;Thanks once again everybody for the help!  &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Store different data types in same array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d9a88997af/?limit=25#021f" rel="alternate"/><published>2020-02-27T13:48:09.545000Z</published><updated>2020-02-27T13:48:09.545000Z</updated><author><name>sgronchi</name><uri>https://forge.codesys.com/u/sgronchi/</uri></author><id>https://forge.codesys.comaec33adfb282967ff06a2bd6fcc9e14e26345d04</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The array would not store objects, just "references" to them. You need to provide storage outside the array (or you go by dynamic memory allocation).&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Store different data types in same array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d9a88997af/?limit=25#c0f7" rel="alternate"/><published>2020-02-27T13:48:09.464000Z</published><updated>2020-02-27T13:48:09.464000Z</updated><author><name>e.kislov</name><uri>https://forge.codesys.com/u/e-kislov/</uri></author><id>https://forge.codesys.com4ccbec1e7c94b342d599dfc9ffc421f1790526dd</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I think, you should use ARRAY &lt;span&gt;[0..5]&lt;/span&gt; OF MyInterface&lt;/p&gt;
&lt;p&gt;Check this:&lt;br/&gt;
&lt;a class="" href="https://industry.plantautomation-technology.com/whitepapers/1485925902-oop-in-iec-061131-3-for-experts.pdf" rel="nofollow"&gt;https://industry.plantautomation-techno ... xperts.pdf&lt;/a&gt; m &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Store different data types in same array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d9a88997af/?limit=25#aaf2" rel="alternate"/><published>2020-02-27T13:48:09.402000Z</published><updated>2020-02-27T13:48:09.402000Z</updated><author><name>dFx</name><uri>https://forge.codesys.com/u/dfx/</uri></author><id>https://forge.codesys.com4240f395783c17047461316ac6bd9ef6c76fd0bd</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Could this be achieved using a union datatype of A and B ?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Store different data types in same array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d9a88997af/?limit=25#850e" rel="alternate"/><published>2020-02-27T13:48:09.316000Z</published><updated>2020-02-27T13:48:09.316000Z</updated><author><name>fatroshi</name><uri>https://forge.codesys.com/u/fatroshi/</uri></author><id>https://forge.codesys.com175f6211ace8e1aad82fcd7c6de2795553456c05</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Is it possible to store different data types in an array if they implement the same interface?&lt;br/&gt;
Or in any other way...?&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;Interface&lt;/span&gt;
&lt;span class="n"&gt;INTERFACE&lt;/span&gt; &lt;span class="n"&gt;MyInterface&lt;/span&gt;
&lt;span class="n"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="n"&gt;A&lt;/span&gt; &lt;span class="n"&gt;IMPLEMENTS&lt;/span&gt; &lt;span class="n"&gt;MyInterface&lt;/span&gt;
&lt;span class="n"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt; &lt;span class="n"&gt;IMPLEMENTS&lt;/span&gt; &lt;span class="n"&gt;MyInterface&lt;/span&gt;
&lt;span class="n"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="n"&gt;Wrapper&lt;/span&gt;
&lt;span class="n"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;ARRAY&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;OF&lt;/span&gt; &lt;span class="o"&gt;???&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;need&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="n"&gt;A&lt;/span&gt; &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt; &lt;span class="n"&gt;objects&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;here&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;possible&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; 
&lt;span class="n"&gt;END_VAR&lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry></feed>