<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/518d3996a8/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/518d3996a8/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/518d3996a8/</id><updated>2020-02-27T23:05:14.001000Z</updated><subtitle>Recent posts to Structs, how do you use them?</subtitle><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#03c4" rel="alternate"/><published>2020-02-27T23:05:14.001000Z</published><updated>2020-02-27T23:05:14.001000Z</updated><author><name>sarathbabu</name><uri>https://forge.codesys.com/u/sarathbabu/</uri></author><id>https://forge.codesys.come40e65bac5993347be3ed263b9d8d3b0c4ead78d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;  &lt;span class="n"&gt;Structures&lt;/span&gt; &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;variables&lt;/span&gt; &lt;span class="n"&gt;too&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;For eg: var_global&lt;br/&gt;
            t_Test:Array &lt;span&gt;[1...5]&lt;/span&gt; of TagAlarm&lt;br/&gt;
          end_var&lt;/p&gt;
&lt;p&gt;Structure TagAlarm can be written as &lt;/p&gt;
&lt;p&gt;Type TagAlarm&lt;br/&gt;
STRUCT&lt;br/&gt;
bFaultSensor:BOOL;&lt;/p&gt;
&lt;p&gt;END_STRUCT&lt;br/&gt;
END_TYPE&lt;/p&gt;
&lt;p&gt;So, the above can be accessed as  t_Test&lt;span&gt;[1]&lt;/span&gt;.bFaultSensor&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#55fd" rel="alternate"/><published>2020-02-27T23:05:09.468000Z</published><updated>2020-02-27T23:05:09.468000Z</updated><author><name>stu1980</name><uri>https://forge.codesys.com/u/stu1980/</uri></author><id>https://forge.codesys.com08b6dd58af5344bcbaaa73cd2147983aea5640b9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Exactly, what you said about the declaration. i just broke the pou declaration into steps.&lt;/p&gt;
&lt;p&gt;Thanks Stu  &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#a509" rel="alternate"/><published>2020-02-27T23:05:07.849000Z</published><updated>2020-02-27T23:05:07.849000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com61c0e61195deebbd1e9bcdb2c24b14fab05be0e6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;In the datastructures you do not declare but you make a definition of a variable.&lt;br/&gt;
declaration is done or in a POU or in the global var list.&lt;/p&gt;
&lt;p&gt;I do not understand fully what you try to do, but most probably it is correct.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#405e" rel="alternate"/><published>2020-02-27T23:05:03.342000Z</published><updated>2020-02-27T23:05:03.342000Z</updated><author><name>stu1980</name><uri>https://forge.codesys.com/u/stu1980/</uri></author><id>https://forge.codesys.com3f0d1252c757be0d5bec5a3895398962b8d49595</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks for the replies, they have helped me greatly. They've help me understand a particular understand the transfer of data. So lets say i have a function where i store two settings e.g. two bools that are true. That i have already declared in struct with the two bools. then declare the struct in a fuction block and use these values when i'am running the main part of program. And use these values e.g. for a particular product test.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#3d1f" rel="alternate"/><published>2020-02-27T23:05:01.707000Z</published><updated>2020-02-27T23:05:01.707000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com390ed792b48085aff640daa980c2d748865e708b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;A structure looks very much like a functionblock.&lt;/p&gt;
&lt;p&gt;You make a structure on the second tab&lt;/p&gt;
&lt;p&gt;TYPE fuzzyunit :&lt;br/&gt;
STRUCT&lt;br/&gt;
    name:STRING (50);&lt;br/&gt;
    membership: ARRAY &lt;span&gt;[0..9]&lt;/span&gt; OF REAL;&lt;br/&gt;
    value: ARRAY &lt;span&gt;[0..9]&lt;/span&gt; OF REAL;&lt;br/&gt;
    namemember: ARRAY &lt;span&gt;[0..9]&lt;/span&gt; OF STRING;&lt;br/&gt;
END_STRUCT&lt;br/&gt;
END_TYPE&lt;br/&gt;
 for example&lt;/p&gt;
&lt;p&gt;Now in the POU you are using you say&lt;br/&gt;
VAR&lt;br/&gt;
workingunit:fuzzyunit;&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;p&gt;in the program you can use workingunit.name:='name of unit';&lt;br/&gt;
or workingunit.membership&lt;span&gt;[3]&lt;/span&gt;:= 0.123;&lt;/p&gt;
&lt;p&gt;for you working with bools:&lt;/p&gt;
&lt;p&gt;TYPE motorstruct&lt;br/&gt;
STRUCT&lt;br/&gt;
xrun:BOOL;&lt;br/&gt;
xlight:BOOL;&lt;br/&gt;
xfail:BOOL;&lt;/p&gt;
&lt;p&gt;in the VARlist add&lt;br/&gt;
motor1:motorstruct;&lt;br/&gt;
motor2:motorstruct;&lt;/p&gt;
&lt;p&gt;in POU&lt;br/&gt;
IF motor1.xrun&lt;br/&gt;
then motor1.xlight:=true;&lt;/p&gt;
&lt;p&gt;It is just a SUBroutine from the VARLIST&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#3d1a" rel="alternate"/><published>2020-02-27T23:04:57.183000Z</published><updated>2020-02-27T23:04:57.183000Z</updated><author><name>t.lundahl</name><uri>https://forge.codesys.com/u/t-lundahl/</uri></author><id>https://forge.codesys.com5b39ac9492ed121ef70e007884979a5730020a93</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;No it's not wrong, it can be used to store parameters. Specially if you are going to save it to a harddisk or CF.&lt;/p&gt;
&lt;p&gt;It is normal variables and can be used as such. It's useful if you want to have many variables transfered between functionblocks.&lt;/p&gt;
&lt;p&gt;Try AXIS : AXIS_REF;&lt;/p&gt;
&lt;p&gt;Add MC.lib/MC2.lib and check out the AXIS_REF going throu the functionblocks.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#691c" rel="alternate"/><published>2020-02-27T23:04:55.556000Z</published><updated>2020-02-27T23:04:55.556000Z</updated><author><name>stu1980</name><uri>https://forge.codesys.com/u/stu1980/</uri></author><id>https://forge.codesys.comf4ff36a9ebb7b67119a6f3e6033e4ede41812171</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;hi, the structs i use at the moment are booleans e.g. using a function with a bools in, then using struct to address the bool in the main program or function block. Is using structs to transfer settings around, is this what they to be used for or do i have the wrong approach?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#b5f2" rel="alternate"/><published>2020-02-27T23:04:53.908000Z</published><updated>2020-02-27T23:04:53.908000Z</updated><author><name>t.lundahl</name><uri>https://forge.codesys.com/u/t-lundahl/</uri></author><id>https://forge.codesys.comaf85036ba4890bd66789d7ea3170bb7d41763021</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;You can use it to structure your IO signals. Structure can be assigned the same way as a normal variable.&lt;/p&gt;
&lt;p&gt;IO.StationX.SensorLimitX&lt;/p&gt;
&lt;p&gt;Little more complext to maintain but if the structure is already done during programming it's easy,&lt;br/&gt;
for example: write IO and press '.' and you get a list of StationsX and press '.' again and you get SensorLimitX.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#1cf7" rel="alternate"/><published>2020-02-27T23:04:49.348000Z</published><updated>2020-02-27T23:04:49.348000Z</updated><author><name>sarathbabu</name><uri>https://forge.codesys.com/u/sarathbabu/</uri></author><id>https://forge.codesys.combb1ff4dd916fad59466fab34fcd5130b730533e8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;          &lt;span class="n"&gt;Can&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;tell&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;much&lt;/span&gt; &lt;span class="n"&gt;detail&lt;/span&gt; &lt;span class="k"&gt;like&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;transfer&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="k"&gt;variable&lt;/span&gt; &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;

&lt;span class="n"&gt;Thanks&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Structs, how do you use them?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/518d3996a8/?limit=25#2e92" rel="alternate"/><published>2020-02-27T23:04:47.720000Z</published><updated>2020-02-27T23:04:47.720000Z</updated><author><name>stu1980</name><uri>https://forge.codesys.com/u/stu1980/</uri></author><id>https://forge.codesys.com155ff346fa5d687de27c53faf2a36a138cc24dac</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, i'm trying to understands structs and there use. Reason being i 'm changing some code but having trouble understanding how data is transfered through structs. Can anyone help?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>