<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to How to stay in a method until something is finished.</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ac839916fa/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ac839916fa/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/ac839916fa/</id><updated>2025-11-04T10:05:26.660000Z</updated><subtitle>Recent posts to How to stay in a method until something is finished.</subtitle><entry><title>How to stay in a method until something is finished.</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ac839916fa/?limit=25#c198/90c4" rel="alternate"/><published>2025-11-04T10:05:26.660000Z</published><updated>2025-11-04T10:05:26.660000Z</updated><author><name>DavidBo</name><uri>https://forge.codesys.com/u/davidbo/</uri></author><id>https://forge.codesys.com604944831becb004ee706ba14ca8fe2c635413ec</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You never stay in a method. You need a block to do that. Something like:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;VAR&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;BOOL&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;FALSE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;UINT&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;0&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;IF&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;THEN&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;read&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;pressure&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;count&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;count&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nt"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;IF&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;count&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;THEN&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;FALSE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="nt"&gt;count&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;END_IF&lt;/span&gt;
&lt;span class="nt"&gt;END_IF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</summary></entry><entry><title>How to stay in a method until something is finished.</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ac839916fa/?limit=25#08a6" rel="alternate"/><published>2025-11-03T04:35:21.618000Z</published><updated>2025-11-03T04:35:21.618000Z</updated><author><name>ben1</name><uri>https://forge.codesys.com/u/ben1/</uri></author><id>https://forge.codesys.come98f127a76adac897aa31072dc546658ab33b2a4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Why must you use a method?&lt;/p&gt;
&lt;p&gt;Top of my head can't you just use the button to turn on a bit and use it in a normal task?&lt;/p&gt;
&lt;p&gt;Just turn a bit on with the button, and run a TON from it in code, and turn it back off with the ton.&lt;/p&gt;
&lt;p&gt;And then just log the pressure on both the rising &amp;amp; falling edge?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to stay in a method until something is finished.</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ac839916fa/?limit=25#c198" rel="alternate"/><published>2025-10-31T21:10:16.020000Z</published><updated>2025-10-31T21:10:16.020000Z</updated><author><name>farren</name><uri>https://forge.codesys.com/u/farren/</uri></author><id>https://forge.codesys.com5e1a79e53b40233deeaa915d61448f638500a2f2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I know I'm thinking about this wrong -- too many decades of procedural and event-driven programming and only a few months of PLC ST programming......&lt;/p&gt;
&lt;p&gt;I've created a visualization with a button that when pushed calls a method.&lt;/p&gt;
&lt;p&gt;I want the method to take a pressure reading, wait one minute and then take another pressure reading.  I'm looking for leaks.  I'm using TON for the delay.&lt;/p&gt;
&lt;p&gt;It seems like what is happening is that the method gets called once and it takes the first reading and starts the TON. But then execution continues, leaves that method call, and the second reading never happens.  I can force the method to keep running until the whole thing is done with a While loop, but I understand that is considered BAD in PLC programming.  If it push the button again to call the method again, it picks up where it left off and if the timer is complete then it runs the remaining code.&lt;/p&gt;
&lt;p&gt;How do I keep that method running until it is complete with just one call without using a while loop that ties up the PLC for a minute?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;-Farren&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>