<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Using VAR_STAT in FB</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8066f90d1a/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8066f90d1a/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/8066f90d1a/</id><updated>2020-02-27T13:53:48.344000Z</updated><subtitle>Recent posts to Using VAR_STAT in FB</subtitle><entry><title>Using VAR_STAT in FB</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8066f90d1a/?limit=25#5068" rel="alternate"/><published>2020-02-27T13:53:48.344000Z</published><updated>2020-02-27T13:53:48.344000Z</updated><author><name>fpin</name><uri>https://forge.codesys.com/u/fpin/</uri></author><id>https://forge.codesys.comaf993a0d8aa45e68dfc99602719548b37937e869</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;rickj hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
As I understand VAR variables declared in the main FB body are already static.  I'm not sure how VAR_STAT is interpreted in the main body, but it probably ends up being something like a class variable, where it's the one and same variable for all instances of the FB.  Try incrementing a VAR_STAT variable on the first execution of the block to see if it counts the number of instances.&lt;br/&gt;
I believe that if you use VAR_STAT in  a method or a function  then you would get the expected behavior.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Ok, thanks for the answer. I will try to increment a VAR_STAT variable when I will have time to do that test.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Using VAR_STAT in FB</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8066f90d1a/?limit=25#c738" rel="alternate"/><published>2020-02-27T13:53:48.134000Z</published><updated>2020-02-27T13:53:48.134000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.come82b547c7e22caa934140198353885936bd27e6a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; rickj&lt;/p&gt;
&lt;p&gt;As I understand VAR variables declared in the main FB body are already static.  I'm not sure how VAR_STAT is interpreted in the main body, but it probably ends up being something like a class variable, where it's the one and same variable for all instances of the FB.  Try incrementing a VAR_STAT variable on the first execution of the block to see if it counts the number of instances.&lt;/p&gt;
&lt;p&gt;I believe that if you use VAR_STAT in  a method or a function  then you would get the expected behavior.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Using VAR_STAT in FB</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8066f90d1a/?limit=25#72dd" rel="alternate"/><published>2020-02-27T13:53:47.564000Z</published><updated>2020-02-27T13:53:47.564000Z</updated><author><name>fpin</name><uri>https://forge.codesys.com/u/fpin/</uri></author><id>https://forge.codesys.com48d50ef4c9a5b058c57656035af961e1d49e481a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi everybody,&lt;/p&gt;
&lt;p&gt;I'm founding some problems with the VAR_STAT in the function block: I don't understand why the variables that I declare in the VAR_STAT field are set to 0 everytime that the function block is called. I tried to not initialized the variables but nothing happens, do I have to set something else?&lt;/p&gt;
&lt;p&gt;I saw that if I use the VAR type I obtain the result that I want but why it should be like this?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>