<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to STRUCTs in a GVL</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e44fc3f12e/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e44fc3f12e/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/e44fc3f12e/</id><updated>2021-03-27T12:39:19.303000Z</updated><subtitle>Recent posts to STRUCTs in a GVL</subtitle><entry><title>STRUCTs in a GVL</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e44fc3f12e/?limit=250#7533/4af6" rel="alternate"/><published>2021-03-27T12:39:19.303000Z</published><updated>2021-03-27T12:39:19.303000Z</updated><author><name>aliazzz</name><uri>https://forge.codesys.com/u/aliazzz/</uri></author><id>https://forge.codesys.com3842de6c8f8b015a88610e2b5f4494363bef6390</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;"In the other program you can nest structures in data block/other structures, and in Codesys you can't do it."&lt;/p&gt;
&lt;p&gt;To nuance, the IEC61131-3 norm (which CODESYS follows really well) does not allow type definition and instancing of DUT data types in a single go. If you wish to read up on this I can recommend this book: &lt;a href="https://link.springer.com/chapter/10.1007%2F978-3-642-12015-2_8" rel="nofollow"&gt;https://link.springer.com/chapter/10.1007%2F978-3-642-12015-2_8&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRUCTs in a GVL</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e44fc3f12e/?limit=25#7533" rel="alternate"/><published>2021-03-27T05:14:45.255000Z</published><updated>2021-03-27T05:14:45.255000Z</updated><author><name>rickj</name><uri>https://forge.codesys.com/u/rickj/</uri></author><id>https://forge.codesys.com73350b7280745066987711b543abe732436a8b3b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Create sub STRUCT &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;TYPE&lt;/span&gt; &lt;span class="n"&gt;sSub&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;STRUCT&lt;/span&gt;
    &lt;span class="n"&gt;Value&lt;/span&gt;   &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="n"&gt;END_TYPE&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Create main STRUCT&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;TYPE&lt;/span&gt; &lt;span class="n"&gt;sMain&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;STRUCT&lt;/span&gt;
    &lt;span class="n"&gt;Value&lt;/span&gt;   &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;SubVal&lt;/span&gt;  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sSub&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="n"&gt;END_TYPE&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Declare and Initialize in GVL&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;VAR_GLOBAL&lt;/span&gt;
    &lt;span class="nt"&gt;NestedStruct&lt;/span&gt;    &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;sMain&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;value&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;SubVal&lt;/span&gt;&lt;span class="o"&gt;:=(&lt;/span&gt;&lt;span class="nt"&gt;Value&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;2&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;Access any variable declared in GVL from a program attached&lt;br/&gt;
to a task, otherwise compiler doesn't bother to compile it.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;Main_PROG&lt;/span&gt;
    &lt;span class="nv"&gt;VAR&lt;/span&gt;
        &lt;span class="nv"&gt;Val&lt;/span&gt; : &lt;span class="nv"&gt;INT&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;END_VAR&lt;/span&gt;

    &lt;span class="nv"&gt;VAL&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;NestedStruct&lt;/span&gt;.&lt;span class="nv"&gt;SubVal&lt;/span&gt;.&lt;span class="nv"&gt;Value&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Compile and go Online to see GVL data&lt;/p&gt;
&lt;p&gt;&lt;img src="./attachment/GVL.png" width="100%"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRUCTs in a GVL</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e44fc3f12e/?limit=25#aad5" rel="alternate"/><published>2021-03-26T14:50:07.789000Z</published><updated>2021-03-26T14:50:07.789000Z</updated><author><name>raxyael</name><uri>https://forge.codesys.com/u/raxyael/</uri></author><id>https://forge.codesys.com32ca0e266bf31386575dc13fd1665b04e6dd714c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Found the solution! I'll post it.&lt;/p&gt;
&lt;p&gt;Thanks again.&lt;/p&gt;
&lt;p&gt;Ryan&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRUCTs in a GVL</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e44fc3f12e/?limit=25#2b04/21fa" rel="alternate"/><published>2021-03-26T14:42:29.297000Z</published><updated>2021-03-26T14:42:29.297000Z</updated><author><name>raxyael</name><uri>https://forge.codesys.com/u/raxyael/</uri></author><id>https://forge.codesys.com0da4e0ebfe17399201d70dc98038205a1bfdfb54</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks! Yep, that solved the first problem!&lt;br/&gt;
Now I got another one, if you could solve it it would be great.&lt;/p&gt;
&lt;p&gt;In the DUT declaration I got some Arrays, and in the GVL I don't know how to initiate it, it gives me an error.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRUCTs in a GVL</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e44fc3f12e/?limit=25#2b04" rel="alternate"/><published>2021-03-26T14:04:35.173000Z</published><updated>2021-03-26T14:04:35.173000Z</updated><author><name>i-campbell</name><uri>https://forge.codesys.com/u/i-campbell/</uri></author><id>https://forge.codesys.comcac8083e5f60a93bd2d0d9b93d3b20e73f3b7006</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Line 4 of your GVL, where you have&lt;br/&gt;
~~~ CL501 : STRUCT_CL501_HMI ( ~~~&lt;br/&gt;
I think should read &lt;br/&gt;
~~~ CL501 : STRUCT_CL501_HMI := ( ~~~&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRUCTs in a GVL</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e44fc3f12e/?limit=25#17cb" rel="alternate"/><published>2021-03-26T12:59:31.828000Z</published><updated>2021-03-26T12:59:31.828000Z</updated><author><name>raxyael</name><uri>https://forge.codesys.com/u/raxyael/</uri></author><id>https://forge.codesys.com7dcfce1993a65f72451f017c66256119908b615b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi everyone and thanks in advance for the replies. I need to rewrite an entire program in Codesys that was written in another program (let's just say that I have to migrate some Data Blocks).&lt;/p&gt;
&lt;p&gt;So I began to copy the program by the variables so I would have everything in place when I would later copy the code itself.&lt;br/&gt;
I wrote down the variables that were in Data Blocks as variables in GVLs, and there was one thing I had to change. In the other program you can nest structures in data block/other structures, and in Codesys you can't do it. So i created an auxiliary folder and declared the STRUCTs I was going to use in the GVLs. &lt;/p&gt;
&lt;p&gt;Everything worked fine, the problem rose when I had to initialize some variables in the GVLs. In the GVL declaration I just wrote down the initial values of the STRUCT following the online helper format, compiled it and nothing went wrong. &lt;br/&gt;
Now if I call a variable in a FB/PRG POU that has been initializated in the GVL it gives me this error: "No Matching "FB_Init" method found for instantiation of STRUCT..."&lt;/p&gt;
&lt;p&gt;I didn't found a useful solution for this problem and I don't really know what to do with the METHOD call. I hope that you can comprehend my explanation and if that's not the case let me know, I will be more than happy to try to explain it better.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>