<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Accessing struct instance property from within function block instance</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3f96edda19/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3f96edda19/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/3f96edda19/</id><updated>2022-11-23T22:52:07.815000Z</updated><subtitle>Recent posts to Accessing struct instance property from within function block instance</subtitle><entry><title>Accessing struct instance property from within function block instance</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3f96edda19/?limit=25#7af5/350b" rel="alternate"/><published>2022-11-23T22:52:07.815000Z</published><updated>2022-11-23T22:52:07.815000Z</updated><author><name>turndapage</name><uri>https://forge.codesys.com/u/turndapage/</uri></author><id>https://forge.codesys.com09ed3d0bab6a035fa80ec47a96cd1945c300e609</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Awesome! That's exactly what I was looking for Thank you!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Accessing struct instance property from within function block instance</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3f96edda19/?limit=25#7af5/d27b" rel="alternate"/><published>2022-11-23T22:52:02.307000Z</published><updated>2022-11-23T22:52:02.307000Z</updated><author><name>turndapage</name><uri>https://forge.codesys.com/u/turndapage/</uri></author><id>https://forge.codesys.com4c033a8860719a6ab4a916b83b19ad14fa2cc678</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Awesome! That's exactly what I was looking for Thank you!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Accessing struct instance property from within function block instance</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3f96edda19/?limit=50#7af5" rel="alternate"/><published>2022-11-23T21:14:51.733000Z</published><updated>2022-11-23T21:14:51.733000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com91559fa0e963a5071437b5891399cbfa339582d0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You can maybe get around this by using a REFERENCE TO in your property.  So your property could look like this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;PROPERTY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;PUBLIC&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CurrentCartridge&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;REFERENCE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CARTRIDGE&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;CurrentCartridge&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;REF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;AllCartridges&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;currentcartridgeindex&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ow"&gt;or&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;whatever&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;backing&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;variable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;called&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The same works with arrays.  Of course, this only works if you have a backing variable to refer to, if you're creating it on the fly, you'll have to use helper variables.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Accessing struct instance property from within function block instance</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3f96edda19/?limit=25#853d" rel="alternate"/><published>2022-11-23T15:59:45.147000Z</published><updated>2022-11-23T15:59:45.147000Z</updated><author><name>turndapage</name><uri>https://forge.codesys.com/u/turndapage/</uri></author><id>https://forge.codesys.come2bbf1a94f99548a471b5b9d6a94efd3fb4f7ed0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi all,&lt;br/&gt;
I've got a structure set up in this way:&lt;/p&gt;
&lt;p&gt;I have a STRUCT called "Cartridge" that has values.&lt;br/&gt;
I have a FB called "Gripper"&lt;br/&gt;
The gripper has a property called "CurrentCartridge" that holds and instance of Cartridge.&lt;/p&gt;
&lt;p&gt;In the program, I want to access the status of the current cartridge.&lt;br/&gt;
If I type this statement:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;IF Gripper1.CurrentCartridge.Status = CartridgeStatus.Inspected THEN&lt;/span&gt;
&lt;span class="err"&gt;    Robot.PlaceWeld(1);&lt;/span&gt;
&lt;span class="err"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I get the error:&lt;br/&gt;
&lt;em&gt;It is not possible to perform component access '.', index access '[]' or call '()' on result of function call. Assign result to help variable first.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;However, if I assign this to a variable, it works:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;G1Cartridge := Gripper1.CurrentCartridge;&lt;/span&gt;
&lt;span class="err"&gt;IF G1Cartridge.Status = CartridgeStatus.Inspected THEN&lt;/span&gt;
&lt;span class="err"&gt;    Robot.PlaceWeld(1);&lt;/span&gt;
&lt;span class="err"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Is there a proper way to do it the first way? this seems really annoying.&lt;br/&gt;
Thank you!&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>