<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Array of FB initialization</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e2b5c93f1d/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e2b5c93f1d/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/e2b5c93f1d/</id><updated>2020-02-27T14:00:14.018000Z</updated><subtitle>Recent posts to Array of FB initialization</subtitle><entry><title>Array of FB initialization</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e2b5c93f1d/?limit=25#e1ed" rel="alternate"/><published>2020-02-27T14:00:14.018000Z</published><updated>2020-02-27T14:00:14.018000Z</updated><author><name>josepmariarams</name><uri>https://forge.codesys.com/u/josepmariarams/</uri></author><id>https://forge.codesys.com367ed15c815b1900d6ef4ecafea2bb9fdc400769</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;It seems that is not possible to pass diferent parameters to the array fb initialization.&lt;/p&gt;
&lt;p&gt;You can, but, initiqlize internal variables as in structures. ( An fb is an structure too).&lt;/p&gt;
&lt;p&gt;Se the post&lt;/p&gt;
&lt;p&gt;l &lt;a class="" href="https://forum.codesys.com/viewtopic.php?p=16838&amp;amp;p=16838&amp;amp;lan=en" rel="nofollow"&gt;viewtopic.php?p=16838#p16838&lt;/a&gt; l &lt;/p&gt;
&lt;p&gt;Be healty!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Array of FB initialization</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e2b5c93f1d/?limit=25#42c8" rel="alternate"/><published>2020-02-27T14:00:13.662000Z</published><updated>2020-02-27T14:00:13.662000Z</updated><author><name>wpmccormick</name><uri>https://forge.codesys.com/u/wpmccormick/</uri></author><id>https://forge.codesys.com7a3e40ea718f069d358658307125570c8c6b38f5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Figured it out ...&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;METHOD&lt;/span&gt; &lt;span class="nt"&gt;FB_Init&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="nt"&gt;FB_FOO&lt;/span&gt;
&lt;span class="nt"&gt;VAR_INPUT&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;bInitRetains&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;BOOL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;bInCopyCode&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;BOOL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;var&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;STRUCT_BAR&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; 
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="nt"&gt;foo&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;ARRAY&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="nx"&gt;..&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt; &lt;span class="nt"&gt;OF&lt;/span&gt; &lt;span class="nt"&gt;FB_FOO&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;bar1&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;bar2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Array of FB initialization</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e2b5c93f1d/?limit=25#4c2f" rel="alternate"/><published>2020-02-27T14:00:13.369000Z</published><updated>2020-02-27T14:00:13.369000Z</updated><author><name>wpmccormick</name><uri>https://forge.codesys.com/u/wpmccormick/</uri></author><id>https://forge.codesys.com3e4aa73e63a72de31488ba4cd80986ced8f2c017</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Trying to figure out how to initialize an array of FB, where the FB itself is initialized with a STRUCT (through the FB_Init).&lt;/p&gt;
&lt;p&gt;&lt;span style="color: underline;"&gt;This works:&lt;/span&gt;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;STRUCT_BAR&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b1&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="n"&gt;val1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b2&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="n"&gt;val2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;FB_FOO&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;span style="color: underline;"&gt;This does not:&lt;/span&gt;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;bar1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;STRUCT_BAR&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b1&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="n"&gt;val1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b2&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="n"&gt;val2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;bar2&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;STRUCT_BAR&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b1&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="n"&gt;val1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b2&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="n"&gt;val2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ARRAY&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;..&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="n"&gt;OF&lt;/span&gt; &lt;span class="n"&gt;FB_FOO&lt;/span&gt;&lt;span class="o"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;bar1&lt;/span&gt;&lt;span class="o"&gt;),(&lt;/span&gt;&lt;span class="n"&gt;bar2&lt;/span&gt;&lt;span class="o"&gt;)];&lt;/span&gt; &lt;span class="c1"&gt;// or like FB_FOO[(bar1,bar2)] and other variations I could think of&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The compile error would look something like:&lt;br/&gt;
&lt;span&gt;[ERROR]&lt;/span&gt;         C0032:  Cannot convert type STRUCT_BAR to type POINTER TO FB_FOO&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>