<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Access variable subrange values</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3c845715cb/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3c845715cb/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/3c845715cb/</id><updated>2020-02-27T13:54:04.965000Z</updated><subtitle>Recent posts to Access variable subrange values</subtitle><entry><title>Access variable subrange values</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3c845715cb/?limit=25#d82c" rel="alternate"/><published>2020-02-27T13:54:04.965000Z</published><updated>2020-02-27T13:54:04.965000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.comf4dc7e8bab4edf4b76bca86fcd354de0a80313a2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;That's an interesting idea, and it almost works for what I have in mind.  The only problem is that I would actually have to change the value of the variable in question in order to test it.&lt;br/&gt;
I set a breakpoint in the CheckRangeSigned function, and it gets the min and max range as inputs to the function, but there's nothing in the call stack to indicate where the inputs come from--the values must be stored in memory somewhere.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Access variable subrange values</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3c845715cb/?limit=25#9c38" rel="alternate"/><published>2020-02-27T13:54:04.757000Z</published><updated>2020-02-27T13:54:04.757000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comb456e49b884c5e2d4bb911705042cf8c667f1e33</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;Brute-force method (assuming you have control of the whole project and can add implicit checks):&lt;/p&gt;
&lt;p&gt;Turn on implicit checks for subrange (CheckRangeSigned and CheckRangeUnsigned).  These POUs will return the value or the limited version of the value.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;PROGRAM&lt;/span&gt; &lt;span class="n"&gt;PLC_PRG&lt;/span&gt;
&lt;span class="n"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;SubrangeINT&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;MaxInt&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;32767&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;MinInt&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;32768&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;Highest&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;Lowest&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;span class="n"&gt;SubrangeINT&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MaxInt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;Highest&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SubrangeINT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;SubrangeINT&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MinInt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;Lowest&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SubrangeINT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;But really, if you have access to the whole project, then you can see the limits by looking at the var definition.  So I don't think this is much help...&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: subrange.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=4399"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Access variable subrange values</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3c845715cb/?limit=25#be63" rel="alternate"/><published>2020-02-27T13:54:04.587000Z</published><updated>2020-02-27T13:54:04.587000Z</updated><author><name>Comingback4u</name><uri>https://forge.codesys.com/u/comingback4u/</uri></author><id>https://forge.codesys.com9f2a1491ee333058e0a12057d64fa6619a8c471d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I am also interested in knowing if there is a way to get the lower and upper limit.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Access variable subrange values</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3c845715cb/?limit=25#3f6d" rel="alternate"/><published>2020-02-27T13:54:04.412000Z</published><updated>2020-02-27T13:54:04.412000Z</updated><author><name>dFx</name><uri>https://forge.codesys.com/u/dfx/</uri></author><id>https://forge.codesys.com8e65ac20c23cae80f252ec365ee2e451c045a8f8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Using constants in déclaration ? Then you may just use thoses constants.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Access variable subrange values</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3c845715cb/?limit=25#6965" rel="alternate"/><published>2020-02-27T13:54:03.817000Z</published><updated>2020-02-27T13:54:03.817000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.comaada98b5043fdf958d3c73b90306a2e54fb78103</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;If I declare a variable like this...&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;TestVar&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4095&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;4095&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;...then I can use implict checks to limit the value of TestVar to the lower and upper limits.&lt;/p&gt;
&lt;p&gt;Is there a way to access the upper and lower limits of a variable?  A function I can call or something?  How are the lower and upper input variables passed to the CheckRangeSigned implicit check function?&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;FUNCTION&lt;/span&gt; &lt;span class="nt"&gt;CheckRangeSigned&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;DINT&lt;/span&gt;
&lt;span class="nt"&gt;VAR_INPUT&lt;/span&gt;
&lt;span class="nt"&gt;value&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;lower&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;upper&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;DINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;thanks&lt;br/&gt;
Tim&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>