<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to initialize variables</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/b2c8160bf1/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/b2c8160bf1/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/b2c8160bf1/</id><updated>2020-02-27T16:38:46.463000Z</updated><subtitle>Recent posts to initialize variables</subtitle><entry><title>initialize variables</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/b2c8160bf1/?limit=25#c65c" rel="alternate"/><published>2020-02-27T16:38:46.463000Z</published><updated>2020-02-27T16:38:46.463000Z</updated><author><name>Thomassmets</name><uri>https://forge.codesys.com/u/thomassmets/</uri></author><id>https://forge.codesys.comde515e1678d32d8f811cfd7983393f163a0c6540</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you !&lt;/p&gt;
&lt;p&gt;I have fixed it with the StartDone Event.&lt;/p&gt;
&lt;p&gt;Thanks for the reply..&lt;/p&gt;
&lt;p&gt;Grz&lt;br/&gt;
Thomas&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>initialize variables</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/b2c8160bf1/?limit=25#c369" rel="alternate"/><published>2020-02-27T16:38:45.593000Z</published><updated>2020-02-27T16:38:45.593000Z</updated><author><name>JAPIB</name><uri>https://forge.codesys.com/u/japib/</uri></author><id>https://forge.codesys.comb78334e335b81d0e3b2dfef41fb2ad45e9846ad3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello&lt;br/&gt;
Only a hot Reset or a cold Reset intialize variables.&lt;br/&gt;
When you build your program, login and start it, it's like a Reset.&lt;/p&gt;
&lt;p&gt;I think you have to write a small program to initialize your variables each time you simply run the program.&lt;/p&gt;
&lt;h2 id="for-exemple"&gt;For exemple :&lt;/h2&gt;
&lt;p&gt;(&lt;em&gt;GVL declaration&lt;/em&gt;)&lt;br/&gt;
VAR&lt;br/&gt;
     xInitialisation_OK :BOOL; (&lt;em&gt;This variable is FALSE each time your PLC start&lt;/em&gt;)&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;(&lt;em&gt;Begin of your program&lt;/em&gt;)&lt;br/&gt;
IF NOT xInitialisation_OK then (&lt;em&gt;IF xInitialisation_OK  is FALSE, it's the first cycle of scrutation&lt;/em&gt;)&lt;br/&gt;
     xvariable1:= ... ; (&lt;em&gt;write the initial value you want &lt;/em&gt;)&lt;br/&gt;
     xvariable2:=... ;&lt;br/&gt;
     ..........&lt;br/&gt;
     xInitialisation_OK :=TRUE; (&lt;em&gt;Initialization is finish&lt;/em&gt;)&lt;br/&gt;
END_IF&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;You can also write this program in a "StartDone" System Event.&lt;/p&gt;
&lt;p&gt;BR  &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>initialize variables</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/b2c8160bf1/?limit=25#9f83" rel="alternate"/><published>2020-02-27T16:38:43.105000Z</published><updated>2020-02-27T16:38:43.105000Z</updated><author><name>Thomassmets</name><uri>https://forge.codesys.com/u/thomassmets/</uri></author><id>https://forge.codesys.com9cd35c0e13db7f24aaef5ddb127a2fb8a1385a5c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Dear all,&lt;br/&gt;
I have tried to initialize my variables (   init: BOOL := 1; ).&lt;br/&gt;
This works the first time I run the program. &lt;br/&gt;
If I stop the program and run it again (or if I build again, login and start the program) its not initialized again.&lt;br/&gt;
How can I fix this ?&lt;br/&gt;
I would like to initialize my variable everytime I start the program.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>