<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Incorrect/Unexpected POU Path Initialization</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0c8bbdc102/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0c8bbdc102/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/0c8bbdc102/</id><updated>2020-11-12T05:58:26.645000Z</updated><subtitle>Recent posts to Incorrect/Unexpected POU Path Initialization</subtitle><entry><title>Incorrect/Unexpected POU Path Initialization</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0c8bbdc102/?limit=25#6186" rel="alternate"/><published>2020-11-12T05:58:26.645000Z</published><updated>2020-11-12T05:58:26.645000Z</updated><author><name>rickj</name><uri>https://forge.codesys.com/u/rickj/</uri></author><id>https://forge.codesys.comf27d5c98275d3b84bf6d2567fafde5e9e35492bf</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Example Project&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Incorrect/Unexpected POU Path Initialization</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0c8bbdc102/?limit=25#c919" rel="alternate"/><published>2020-11-12T05:56:04.712000Z</published><updated>2020-11-12T05:56:04.712000Z</updated><author><name>rickj</name><uri>https://forge.codesys.com/u/rickj/</uri></author><id>https://forge.codesys.com5494a24427949181914d45fae81e420b3b8869bc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I created a function block to initialize its Path string variable to the function block's path using the appropriate attribute pragmas as shown below.  An instance of this function block in the main program is initialized to the correct and expected path. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="s1"&gt;'reflection'&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="n"&gt;PathTestFunctionFB&lt;/span&gt; 

&lt;span class="n"&gt;VAR&lt;/span&gt;
    &lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="s1"&gt;'instance-path'&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
    &lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="s1"&gt;'noinit'&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;Path&lt;/span&gt;        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;STRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I created a second function block in the same manner that also contains an instance of the first. An instance of this block, in the main program, and its instance of the first block are initialized correctly and as expected.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="s1"&gt;'reflection'&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="n"&gt;PathTestBaseFB&lt;/span&gt;
&lt;span class="n"&gt;VAR_INPUT&lt;/span&gt;
    &lt;span class="n"&gt;PathTestFunction&lt;/span&gt;    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;PathTestFunctionFB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;

&lt;span class="n"&gt;VAR&lt;/span&gt;
    &lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="s1"&gt;'instance-path'&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
    &lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="s1"&gt;'noinit'&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;Path&lt;/span&gt;        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;STRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I created a third function block which extends the second block as shown below.  This block does not contain attribute pragmas or variable declarations. Instead, it inherits everything from the second function block. An instance of this block in the main program initializes both inherited path variables for Base and Function function blocks to the same value, which seems to be incorrect or at least unexpected.  &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="n"&gt;PathTestDerivedFB&lt;/span&gt; &lt;span class="n"&gt;EXTENDS&lt;/span&gt; &lt;span class="n"&gt;PathTestBaseFB&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;An example project and screen shot of the initialized path variables are attached.&lt;/p&gt;
&lt;p&gt;[[PathTest.png]]&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>