<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to [OOP] How to implement "HAS A"... that is, instance of class within a class</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/</id><updated>2020-02-27T14:07:54.800000Z</updated><subtitle>Recent posts to [OOP] How to implement "HAS A"... that is, instance of class within a class</subtitle><entry><title>[OOP] How to implement "HAS A"... that is, instance of class within a class</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/?limit=25#ec75" rel="alternate"/><published>2020-02-27T14:07:54.800000Z</published><updated>2020-02-27T14:07:54.800000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comeb8b10c0455203c0d32af93590ce30d6fbcf256c</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;Here is a screen shot of your solution using a property and REFERENCE TO.  You have access to all of subsystem's methods and properties.  You do not have access to subsystem's internal VARs like mySubInt (the only debugger does, however).  I used the property CurrentCount for that.  (You could have a Set function for CurrentCount, and then you basically have access to your internal var).&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: has" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=2818"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>[OOP] How to implement "HAS A"... that is, instance of class within a class</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/?limit=25#109a" rel="alternate"/><published>2020-02-27T14:07:54.418000Z</published><updated>2020-02-27T14:07:54.418000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.coma282a8b982fccf0aa18f206a78ee46893c9b179b</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;You can also define the object as a VAR in your function block and then create a property for your function block that returns a reference to the object. Only create the get - delete the set. You can then have access to the internal object's methods and properties.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>[OOP] How to implement "HAS A"... that is, instance of class within a class</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/?limit=25#86b9" rel="alternate"/><published>2020-02-27T14:07:54.081000Z</published><updated>2020-02-27T14:07:54.081000Z</updated><author><name>jcpershe</name><uri>https://forge.codesys.com/u/jcpershe/</uri></author><id>https://forge.codesys.com6d96ae21693843e3470e804d67123447e496fc65</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Josep M. Rams hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
If you want to acces variables outside fb you habe to declare its as var_input.&lt;br/&gt;
But is a best practice to acces its via methotds (get set).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thank you.  That was the issue.  I plan to use the methods for the member instances, but I could not "see" the member methods and properties until I moved the variable to VAR_INPUT.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;br/&gt;
jcp &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>[OOP] How to implement "HAS A"... that is, instance of class within a class</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/?limit=25#1753" rel="alternate"/><published>2020-02-27T14:07:53.766000Z</published><updated>2020-02-27T14:07:53.766000Z</updated><author><name>chris.beard</name><uri>https://forge.codesys.com/u/chris-beard/</uri></author><id>https://forge.codesys.com28f4b087bc01c37886fc674c2320ccde8891aa85</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;For true OOP you should be able to make the new fb with the extends or implements setting and then also use the super command too see the following as a good example. &lt;a class="" href="https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/18014398645427339.html&amp;amp;id=" rel="nofollow"&gt;https://infosys.beckhoff.com/english.ph ... 9.html&amp;amp;id=&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Sent from my SM-N9005 using Tapatalk&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>[OOP] How to implement "HAS A"... that is, instance of class within a class</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/?limit=25#1463" rel="alternate"/><published>2020-02-27T14:07:52.747000Z</published><updated>2020-02-27T14:07:52.747000Z</updated><author><name>josepmariarams</name><uri>https://forge.codesys.com/u/josepmariarams/</uri></author><id>https://forge.codesys.com3b28e5c91f9a0f204aa9cfc8814b1ff1750840c1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;If you want to acces variables outside fb you habe to declare its as var_input.&lt;/p&gt;
&lt;p&gt;But is a best practice to acces its via methotds (get set).&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>[OOP] How to implement "HAS A"... that is, instance of class within a class</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/?limit=25#7257" rel="alternate"/><published>2020-02-27T14:07:52.299000Z</published><updated>2020-02-27T14:07:52.299000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.combead806ee4b186667bf4a7d757565b67152d9809</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;Your problem is scope of variables. Items defined as VARs of FBs are not available outside of the FB.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>[OOP] How to implement "HAS A"... that is, instance of class within a class</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/787251d83b/?limit=25#de08" rel="alternate"/><published>2020-02-27T14:07:51.908000Z</published><updated>2020-02-27T14:07:51.908000Z</updated><author><name>jcpershe</name><uri>https://forge.codesys.com/u/jcpershe/</uri></author><id>https://forge.codesys.coma86601a38d8746a4819b35d134d8614dab7a31b6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have created a class (FB with Methods and Properties).&lt;/p&gt;
&lt;p&gt;I would like one the variables within this class to be another class (FB with Methods and Properties).&lt;/p&gt;
&lt;p&gt;But when I try to use F2 to enter a specific method or property of the instance within the instance, I cannot find the instance within.&lt;/p&gt;
&lt;p&gt;I would like to access the elements something like:&lt;br/&gt;
ourLargeSystem&lt;span&gt;[3]&lt;/span&gt;.mySubSystem.mySubInt := 4;&lt;/p&gt;
&lt;p&gt;This doesn't seem to work. I get an error that 'mySubSystem' is not an input of largeSystem.&lt;/p&gt;
&lt;p&gt;Here's some pseudo-code.  What I am doing wrong.&lt;/p&gt;
&lt;p&gt;Thanks for any ideas.  I must be missing something.&lt;br/&gt;
JP&lt;/p&gt;
&lt;p&gt;GlobalVariables&lt;br/&gt;
    ourLargeSystems : ARRRAY&lt;span&gt;[1..10]&lt;/span&gt; OF largeSystem;&lt;br/&gt;
END Global Variables&lt;/p&gt;
&lt;p&gt;FB largeSystem&lt;br/&gt;
VAR&lt;br/&gt;
_myInt : INT;&lt;br/&gt;
_myReal : REAL;&lt;br/&gt;
mySubSystem : subSystem&lt;/p&gt;
&lt;p&gt;END_VAR&lt;br/&gt;
etc... with Methods and Properties&lt;/p&gt;
&lt;p&gt;FB subSystem&lt;br/&gt;
VAR&lt;br/&gt;
_mySubInt : INT;&lt;br/&gt;
END_VAR&lt;br/&gt;
etc. with Methods and Properties&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>