<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to VAR_STAT in METHOD of a PROGRAM</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eab4cf5717/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eab4cf5717/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/eab4cf5717/</id><updated>2020-08-26T11:01:45.579000Z</updated><subtitle>Recent posts to VAR_STAT in METHOD of a PROGRAM</subtitle><entry><title>VAR_STAT in METHOD of a PROGRAM</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eab4cf5717/?limit=250#bd4b" rel="alternate"/><published>2020-08-26T11:01:45.579000Z</published><updated>2020-08-26T11:01:45.579000Z</updated><author><name>aliazzz</name><uri>https://forge.codesys.com/u/aliazzz/</uri></author><id>https://forge.codesys.com4d851c1f5b88d9b6299850ed2c15e33e96e9b24c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Indeed, VAR_STAT can be seen as if a variable is declared in the body of the main POU (so an FB or a PROGRAM). In techspeak: the declaration of the VAR_STAT is placed on the stack of the parent POU, instead of on the stack of the METHOD itself.&lt;/p&gt;
&lt;p&gt;To sum it up: 'regular' variables in the METHOD declaration lose their contents after ending the METHOD, while VAR_STAT variables never lose their content after ending the METHOD. &lt;/p&gt;
&lt;p&gt;I Hope this anwsers your question.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>VAR_STAT in METHOD of a PROGRAM</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eab4cf5717/?limit=25#3d55" rel="alternate"/><published>2020-08-26T10:43:57.990000Z</published><updated>2020-08-26T10:43:57.990000Z</updated><author><name>massimo</name><uri>https://forge.codesys.com/u/massimo/</uri></author><id>https://forge.codesys.com698e2356bb1f3b60b046f8d79a9037bfbd377720</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Situation:&lt;br/&gt;
- I have a program with many methods.&lt;br/&gt;
- Some methods use fb/vars that need memory between one call and next call&lt;/p&gt;
&lt;p&gt;If a won't declare it in program body, how i can proceed? I found VAR_STAT and test it, with success.&lt;/p&gt;
&lt;p&gt;Help says that static variables retain their value when the application exits the function block&lt;/p&gt;
&lt;p&gt;It is true also for PROGRAMS?&lt;/p&gt;
&lt;p&gt;Thank's in advance&lt;/p&gt;
&lt;p&gt;Massimo&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>