<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Initialization of visualization variables and cyclic code execution</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0df09d70c0/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0df09d70c0/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/0df09d70c0/</id><updated>2023-10-01T13:26:12.451000Z</updated><subtitle>Recent posts to Initialization of visualization variables and cyclic code execution</subtitle><entry><title>Initialization of visualization variables and cyclic code execution</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0df09d70c0/?limit=25#e4c0" rel="alternate"/><published>2023-10-01T13:26:12.451000Z</published><updated>2023-10-01T13:26:12.451000Z</updated><author><name>sturmghost</name><uri>https://forge.codesys.com/u/sturmghost/</uri></author><id>https://forge.codesys.com6d8fdad09481dcb0a7c67635799117742f0d10b9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I'm looking for a smart and short way to implement initialization of visualization variables &lt;strong&gt;depending on the visualization input&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;For an easy example consider a rectangle which rests at XPos := 0 when the input state is false and at XPos := 50 when the input stat is true. My visualization variables look like this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;VAR_IN_OUT&lt;/span&gt;
    &lt;span class="n"&gt;State&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;span class="kr"&gt;VAR&lt;/span&gt;
    &lt;span class="n"&gt;XPos&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I put this rectangle via a visualization frame element into another visualization and link a frame reference variable with the state to it.&lt;/p&gt;
&lt;p&gt;If the variable is true, the rectangle should rest at XPos := 50 and false at XPos := 0 at visualization init but how should I assign the 50 or 0 to the internal visualization variable XPos? I would need some init-methode for the visualization but I dont want a global init-method for such tasks. I want to do it inside of the visualization element but I can't see any solution for this? &lt;/p&gt;
&lt;p&gt;It would be good to be able to define ST-code within the visualization element which runs cyclic at each VISU_TASK task-cycle then I could just check the input state and change the XPos accordingly. &lt;/p&gt;
&lt;p&gt;Does someone have a solution?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>