<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Counter with specific number of digits</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/cf324f253a/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/cf324f253a/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/cf324f253a/</id><updated>2020-02-27T20:44:18.316000Z</updated><subtitle>Recent posts to Counter with specific number of digits</subtitle><entry><title>Counter with specific number of digits</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/cf324f253a/?limit=25#48c4" rel="alternate"/><published>2020-02-27T20:44:18.316000Z</published><updated>2020-02-27T20:44:18.316000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com587cdb52d779d1b527432e40c25f3fa4a968ea1d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;have a look at  w &lt;a class="" href="http://www.oscat.de" rel="nofollow"&gt;www.oscat.de&lt;/a&gt; w  for a nice library containing all sorts of manipulation, and yes you may be proud of your solution.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Counter with specific number of digits</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/cf324f253a/?limit=25#92b0" rel="alternate"/><published>2020-02-27T20:44:16.887000Z</published><updated>2020-02-27T20:44:16.887000Z</updated><author><name>mravlincek</name><uri>https://forge.codesys.com/u/mravlincek/</uri></author><id>https://forge.codesys.com8e039a5707633077900b367e5fa367a3276ba3a1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I actually made it happen like this, because I am not familiar with repeat of while funcitons as yet &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;STRINGcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;DWORD_TO_STRING&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;DWORDcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;LEN&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;STRINGcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;STRINGcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;ELSIF&lt;/span&gt; &lt;span class="nv"&gt;LEN&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;STRINGcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;STRINGcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CONCAT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
.
.
.
&lt;span class="nv"&gt;ELSIF&lt;/span&gt; &lt;span class="nv"&gt;LEN&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;STRINGcounter&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="nv"&gt;TEMPcounter&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;STRINGcounter&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I am not proud of it but it works &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Counter with specific number of digits</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/cf324f253a/?limit=25#31a3" rel="alternate"/><published>2020-02-27T20:44:12.973000Z</published><updated>2020-02-27T20:44:12.973000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comaf4e6c1a56c87bb23fb1921843f29a1fd257493f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;First, make sure your counter supports the high number (you need a dword output). Then you Use DWORD_TO_STRING to get the number as a string. Also define a string '0000000'. Concat the two together and then your answer is MID(togetherstring, LEN(togetherstring)-7,7). Or about that&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Counter with specific number of digits</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/cf324f253a/?limit=25#12de" rel="alternate"/><published>2020-02-27T20:44:11.579000Z</published><updated>2020-02-27T20:44:11.579000Z</updated><author><name>mravlincek</name><uri>https://forge.codesys.com/u/mravlincek/</uri></author><id>https://forge.codesys.com762827546906504b9e0369f142a0adeda2ddb120</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi all.&lt;/p&gt;
&lt;p&gt;So I am having this strange problem, where I need specific number of digits in my counter. I need the counter to be able to count up to 9999999, but the number of digits always has to be the same. This means, when the counter starts it should be 0000001, then later on it will be 0001021 and so on.&lt;/p&gt;
&lt;p&gt;I would prefer to convert the counter into string later on, so maybe there is a solution there? I am completely out of ideas on how to easily realize this. &lt;/p&gt;
&lt;p&gt;Please help &lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>