<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Question about struct arrays</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/17430f41ec/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/17430f41ec/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/17430f41ec/</id><updated>2020-04-23T12:55:11.667000Z</updated><subtitle>Recent posts to Question about struct arrays</subtitle><entry><title>Question about struct arrays</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/17430f41ec/?limit=25#afce/1e5a" rel="alternate"/><published>2020-04-23T12:55:11.667000Z</published><updated>2020-04-23T12:55:11.667000Z</updated><author><name>epinikion</name><uri>https://forge.codesys.com/u/epinikion/</uri></author><id>https://forge.codesys.com51ddb63cd7b78c87260b1a65ae90bca1c85ffbbb</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Great, that works too! Many thanks.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Question about struct arrays</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/17430f41ec/?limit=25#afce" rel="alternate"/><published>2020-04-22T16:17:48.232000Z</published><updated>2020-04-22T16:17:48.232000Z</updated><author><name>Comingback4u</name><uri>https://forge.codesys.com/u/comingback4u/</uri></author><id>https://forge.codesys.comc43a9b2b9065e52cf2b574af2a599015beea172d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You can try using VAR_TEMP as that will assign the values every time your function block is called. So as long as your input variables have been set, Daten will update on your next call to your FB. You won't be able to see those values during runtime as once the function block has finished it's call it will destroy the variable. Otherwise I'm not sure what your end goal is it is harder to make suggestions.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;You&lt;/span&gt; &lt;span class="nt"&gt;can&lt;/span&gt; &lt;span class="nt"&gt;try&lt;/span&gt; &lt;span class="nt"&gt;moving&lt;/span&gt; &lt;span class="nt"&gt;your&lt;/span&gt; &lt;span class="nt"&gt;var&lt;/span&gt; &lt;span class="nt"&gt;here&lt;/span&gt;
&lt;span class="nt"&gt;VAR_TEMP&lt;/span&gt;
    &lt;span class="nt"&gt;Daten&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                          &lt;span class="nt"&gt;ARRAY&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="nx"&gt;..7&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt; &lt;span class="nt"&gt;OF&lt;/span&gt; &lt;span class="nt"&gt;TestData&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sSerialNummer&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'4'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sAssemblyName&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'6'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sTesterType&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'7'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sTesterID&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'8'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sTestName&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'13'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;DATE_TO_STRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dDate&lt;/span&gt;&lt;span class="p"&gt;)),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'14'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;TOD_TO_STRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todTime&lt;/span&gt;&lt;span class="p"&gt;)),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'16'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sTestResult&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="cp"&gt;]&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;/div&gt;</summary></entry><entry><title>Question about struct arrays</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/17430f41ec/?limit=25#77b0/24f8" rel="alternate"/><published>2020-04-22T10:24:48.016000Z</published><updated>2020-04-22T10:24:48.016000Z</updated><author><name>epinikion</name><uri>https://forge.codesys.com/u/epinikion/</uri></author><id>https://forge.codesys.comaae050a81b6a1c71203ec800a0b36c872b46f298</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you for your answer, I will take a look. Is it possible to define the variable in the program instead of in the variable definitions in order to spare me the fb_init? I think not, right? &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Question about struct arrays</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/17430f41ec/?limit=25#77b0" rel="alternate"/><published>2020-04-21T16:18:44.780000Z</published><updated>2020-04-21T16:18:44.780000Z</updated><author><name>Comingback4u</name><uri>https://forge.codesys.com/u/comingback4u/</uri></author><id>https://forge.codesys.com0324cdae3d930759156b6ac8363b281b84a06d5e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The Daten array gets initialized before your input variables are set. You need somewhere to update the Daten array "data" to match the input variables that are defined in your function block call or initialization. If you want to set them on intialization you might want to look into setting up a fb_init method for that function block.&lt;br/&gt;
More on fb_init can be found here: &lt;a href="https://help.codesys.com/webapp/_cds_method_fb_init_fb_reinit;product=codesys;version=3.5.15.0#interface-of-method-fb-init" rel="nofollow"&gt;https://help.codesys.com/webapp/_cds_method_fb_init_fb_reinit;product=codesys;version=3.5.15.0#interface-of-method-fb-init&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Question about struct arrays</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/17430f41ec/?limit=25#35b5" rel="alternate"/><published>2020-04-21T13:25:12.968000Z</published><updated>2020-04-21T13:25:12.968000Z</updated><author><name>epinikion</name><uri>https://forge.codesys.com/u/epinikion/</uri></author><id>https://forge.codesys.com2b0485823c375c81207e4173a1f1d566467f35ad</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I made a FB which has as input several string variables. Inside the FB I declare a variable consisting of a struct array of said inputs (this struct is made just of strings). These are later formated in a specific way and saved in a .txt file.&lt;/p&gt;
&lt;p&gt;My problem is when I go online, even I see the desired strings on the input variables, on the array they´re all empty and my text file comes out as just comas and line breaks (which I write on my FB). It only works if I manually write the strings on the array.&lt;/p&gt;
&lt;p&gt;Here´s the DUT, just some strings:&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;TestData&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="nt"&gt;STRUCT&lt;/span&gt;
    &lt;span class="nt"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                  &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nt"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                   &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;''&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_TYPEde&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;And here a snippet of the variables on my FB:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;VAR_INPUT&lt;/span&gt;

    &lt;span class="nt"&gt;sTagOben&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                       &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;sTagUnten&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                      &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;sSerialNummer&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                  &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;sAssemblyName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                  &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;sTesterType&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                    &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;sTesterID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                      &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;sTestName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                      &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;sTestResult&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                    &lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;dDate&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                          &lt;span class="nt"&gt;DATE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;todTime&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                        &lt;span class="nt"&gt;TIME_OF_DAY&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;


&lt;span class="nt"&gt;END_VAR&lt;/span&gt;

&lt;span class="nt"&gt;VAR&lt;/span&gt;

&lt;span class="nt"&gt;Daten&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                          &lt;span class="nt"&gt;ARRAY&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="nx"&gt;..7&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt; &lt;span class="nt"&gt;OF&lt;/span&gt; &lt;span class="nt"&gt;TestData&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sSerialNummer&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'4'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sAssemblyName&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'6'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sTesterType&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'7'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sTesterID&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'8'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sTestName&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'13'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;DATE_TO_STRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dDate&lt;/span&gt;&lt;span class="p"&gt;)),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'14'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;TOD_TO_STRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todTime&lt;/span&gt;&lt;span class="p"&gt;)),(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'16'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nx"&gt;sTestResult&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The index show properly, as I defined them there manually. Any suggestions? Is it not possible to define inputs and right away call them in a defined variable?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>