<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to structured variable as property</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1d77aeb93e/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1d77aeb93e/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/1d77aeb93e/</id><updated>2020-02-27T14:23:58.175000Z</updated><subtitle>Recent posts to structured variable as property</subtitle><entry><title>structured variable as property</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1d77aeb93e/?limit=25#0561" rel="alternate"/><published>2020-02-27T14:23:58.175000Z</published><updated>2020-02-27T14:23:58.175000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com542e580112003f5db0f4e115a057eb55a7d94e20</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;Properties are like a special get method or set method. They actually run as code when you call them (you can see when you online debug and step through).&lt;/p&gt;
&lt;p&gt;I would probably avoid using properties for HMI use - I typically define a structure T_HMI and list out the variables I am transferring and the. Have one program that copies speaking variables from different parts of the program into the one structure.   Use VAR ins/outs and inOuts for linking to HMIs. &lt;/p&gt;
&lt;p&gt;I typically define the HMI structure as global and then in my FBs that either give or receive data from the HMI, I define REFERENCE TOs on var ins, car outs or var inouts. Then I set the reference to the element in the global structure. &lt;/p&gt;
&lt;p&gt;But that is, of course, only my way of doing things.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>structured variable as property</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1d77aeb93e/?limit=25#3185" rel="alternate"/><published>2020-02-27T14:23:56.980000Z</published><updated>2020-02-27T14:23:56.980000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com6f015860ba37faaa25d4b8bdb07c215b86d07a42</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;So if I understand correctly, a property isn't initialized until it is called from somewhere outside the function block in which it resides.  If that's the case I might have to revise my design, as a lot of the status variable properties are strictly for display on an HMI.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>structured variable as property</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1d77aeb93e/?limit=25#5e8e" rel="alternate"/><published>2020-02-27T14:23:56.511000Z</published><updated>2020-02-27T14:23:56.511000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comf719664203ebbb9b7965226c4e58c711b5a7d444</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;Have you called the property?  The code doesn't run (i.e. Status is referring to nothing until you call it!).  Also, I get a program exception as soon as a assign the attribute monitor to the property (probably because it is not initialized to refer to anything).&lt;/p&gt;
&lt;p&gt;I duplicated your project and it is working (I forced some values into _Status):&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;PROGRAM&lt;/span&gt; &lt;span class="n"&gt;PLC_PRG&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;Test&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;MyFbWithRef&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;Res&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;T_STRUCT&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;Res&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Status&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&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;MyFbWithRef&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;_Status&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;T_STRUCT&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;PROPERTY&lt;/span&gt; &lt;span class="n"&gt;Status&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;REFERENCE&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="n"&gt;T_STRUCT&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;Status&lt;/span&gt; &lt;span class="k"&gt;REF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_Status&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;TYPE&lt;/span&gt; &lt;span class="nt"&gt;T_STRUCT&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="nt"&gt;STRUCT&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;Status1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;INT&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;Status2&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="nt"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="nt"&gt;END_TYPE&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Here is my result:&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: before" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=2996"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: after" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=2997"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>structured variable as property</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1d77aeb93e/?limit=25#c88e" rel="alternate"/><published>2020-02-27T14:23:56.085000Z</published><updated>2020-02-27T14:23:56.085000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.combdc7e04a24f441675509e6e99a9b3b8c8b2615f5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I've been trying to define a property as a structured variable.  It seems that it's not possible to do it directly (see  l &lt;a class="" href="https://forum.codesys.com/viewtopic.php?t=5577" rel="nofollow"&gt;viewtopic.php?t=5577&lt;/a&gt; l ), so I followed the advice in that thread and used a reference.  That appears to work as far as programming and compiling goes, however, I'm not seeing the variables when I go online with the controller.  The little + sign is there, but when I click on it it disappears, and there's no variables.  I've used both {attribute 'monitoring':='variable'} and {attribute 'monitoring':='call'}.  "variable" will crash the controller with some of the larger structures.  &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;TYPE&lt;/span&gt; &lt;span class="nt"&gt;STRUCTUREDVARIABLE&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="nt"&gt;STRUCT&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;Status1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;INT&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;Status2&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="nt"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="nt"&gt;END_TYPE&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;attribute&lt;/span&gt; &lt;span class="err"&gt;'monitoring':='variable'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;PROPERTY&lt;/span&gt; &lt;span class="nt"&gt;Status&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;REFERENCE&lt;/span&gt; &lt;span class="nt"&gt;TO&lt;/span&gt; &lt;span class="nt"&gt;STRUCTUREDVARIABLE&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;Status&lt;/span&gt; &lt;span class="nt"&gt;REF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;_Status&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="nt"&gt;TestPOU&lt;/span&gt;
&lt;span class="nt"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;_Status&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;STRUCTUREDVARIABLE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;img alt="IMG: Capture.PNG" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=2994"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>