<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Bit access to  DWORD Variable</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/fa7a703b16/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/fa7a703b16/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/fa7a703b16/</id><updated>2020-02-27T16:28:15.677000Z</updated><subtitle>Recent posts to Bit access to  DWORD Variable</subtitle><entry><title>Bit access to  DWORD Variable</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/fa7a703b16/?limit=25#5442" rel="alternate"/><published>2020-02-27T16:28:15.677000Z</published><updated>2020-02-27T16:28:15.677000Z</updated><author><name>lucaver89</name><uri>https://forge.codesys.com/u/lucaver89/</uri></author><id>https://forge.codesys.com901b49eea8a4fcf59ce96153f8c14b7799dd13da</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;D. Kugler hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
&lt;a href="https://help.codesys.com/webapp/extract;product=codesys;version=3.5.11.0" rel="nofollow"&gt;https://help.codesys.com/webapp/extract;product=codesys;version=3.5.11.0&lt;/a&gt;&lt;br/&gt;
That's what you are searching for?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Absolulty Yes! Thank you very much!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Bit access to  DWORD Variable</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/fa7a703b16/?limit=25#d654" rel="alternate"/><published>2020-02-27T16:28:13.280000Z</published><updated>2020-02-27T16:28:13.280000Z</updated><author><name>lucaver89</name><uri>https://forge.codesys.com/u/lucaver89/</uri></author><id>https://forge.codesys.com02c82907a94812c691675c8de28e8098846afaa5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;JAPIB hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
I'm sory, I don't understand this :  "IF(my_word.my_word)..."&lt;br/&gt;
I think you wanted to write  "IF(my_word. scan_bit)..."&lt;br/&gt;
To my knowledge you can't use a variable to acces a bit of a word (it is the same with SINT, INT, DINT, USINT, UDINT, BYTE, WORD, DWORD)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr/&gt;
&lt;p&gt;To acces to a bit of a word you can only use : &lt;br/&gt;
- a value, for example you can test (or write ) "my_word.2" or "my_word.5" ...&lt;br/&gt;
- a Global Constant &lt;br/&gt;
VAR_GLOBAL CONSTANT&lt;br/&gt;
 Indice:INT:=2;&lt;br/&gt;
END_VAR&lt;br/&gt;
And you can test (or write ) "my_word.Indice"&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;One solution to test each bit of a word may be to use SHL/SHR operators to shift and test each bit.&lt;br/&gt;
You can see CODESYS HELP : &lt;a class="" href="https://help.codesys.com/webapp/_cds_operator_shl;product=codesys;version=3.5.15.0" rel="nofollow"&gt;https://help.codesys.com/webapp/_cds_op ... n=3.5.15.0&lt;/a&gt;&lt;br/&gt;
BR&lt;/p&gt;
&lt;p&gt;Sorry for my error, yes You have right should be ```&lt;/p&gt;
&lt;p&gt;IF(my_word. scan_bit)&lt;/p&gt;
&lt;p&gt;``` &lt;br/&gt;
Thank you for help&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Bit access to  DWORD Variable</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/fa7a703b16/?limit=25#d388" rel="alternate"/><published>2020-02-27T16:28:12.439000Z</published><updated>2020-02-27T16:28:12.439000Z</updated><author><name>dFx</name><uri>https://forge.codesys.com/u/dfx/</uri></author><id>https://forge.codesys.comb823185a922e62f0886b1603a36f50a29efd14c2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;This could provide a nice access :&lt;a class="" href="https://forum.codesys.com/viewtopic.php?t=9449&amp;amp;p=23426&amp;amp;lan=en" rel="nofollow"&gt;see this post&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Bit access to  DWORD Variable</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/fa7a703b16/?limit=25#eeba" rel="alternate"/><published>2020-02-27T16:28:10.006000Z</published><updated>2020-02-27T16:28:10.006000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com6bea77b9b9cb61a843be962ea8f0da34fd288ab6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; D. Kugler&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://help.codesys.com/webapp/extract;product=codesys;version=3.5.11.0" rel="nofollow"&gt;https://help.codesys.com/webapp/extract ... n=3.5.11.0&lt;/a&gt;&lt;br/&gt;
That's what you are searching for?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Bit access to  DWORD Variable</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/fa7a703b16/?limit=25#72fe" rel="alternate"/><published>2020-02-27T16:28:09.090000Z</published><updated>2020-02-27T16:28:09.090000Z</updated><author><name>JAPIB</name><uri>https://forge.codesys.com/u/japib/</uri></author><id>https://forge.codesys.comaedc24d3f9d20e6d3d85a6fee76ad0ad825a31fb</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I'm sory, I don't understand this :  "IF(my_word.my_word)..."&lt;/p&gt;
&lt;p&gt;I think you wanted to write  "IF(my_word. scan_bit)..."&lt;/p&gt;
&lt;p&gt;To my knowledge you can't use a variable to acces a bit of a word (it is the same with SINT, INT, DINT, USINT, UDINT, BYTE, WORD, DWORD)&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;To acces to a bit of a word you can only use : &lt;br/&gt;
- a value, for example you can test (or write ) "my_word.2" or "my_word.5" ...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a Global Constant &lt;br/&gt;
VAR_GLOBAL CONSTANT&lt;br/&gt;
 Indice:INT:=2;&lt;br/&gt;
END_VAR&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="and-you-can-test-or-write-my_wordindice"&gt;And you can test (or write ) "my_word.Indice"&lt;/h2&gt;
&lt;p&gt;One solution to test each bit of a word may be to use SHL/SHR operators to shift and test each bit.&lt;br/&gt;
You can see CODESYS HELP : &lt;a class="" href="https://help.codesys.com/webapp/_cds_operator_shl;product=codesys;version=3.5.15.0" rel="nofollow"&gt;https://help.codesys.com/webapp/_cds_op ... n=3.5.15.0&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Bit access to  DWORD Variable</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/fa7a703b16/?limit=25#ac84" rel="alternate"/><published>2020-02-27T16:28:08.088000Z</published><updated>2020-02-27T16:28:08.088000Z</updated><author><name>lucaver89</name><uri>https://forge.codesys.com/u/lucaver89/</uri></author><id>https://forge.codesys.com8e78e8739250da6a97b201650a0268318cbf269e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi to all,&lt;/p&gt;
&lt;p&gt;the following code give me the following error "access requires a literal or an integer symbolic constant"&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&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;PROGRAM&lt;/span&gt; &lt;span class="n"&gt;PLC_PRG&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&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;VAR&lt;/span&gt;
&lt;span class="err"&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;my_word&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt;  &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;DWORD&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="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;scan_bit&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt;  &lt;/span&gt; &lt;span class="err"&gt; &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="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt;  &lt;/span&gt; &lt;span class="err"&gt;  &lt;/span&gt; &lt;span class="err"&gt; &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="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;   &lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="nv"&gt;scan_bit&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="nv"&gt;TO&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="nv"&gt;BY&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;DO&lt;/span&gt;
   
      &lt;span class="k"&gt;IF&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;my_word&lt;/span&gt;.&lt;span class="nv"&gt;my_word&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
         &lt;span class="nv"&gt;test&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;ELSE&lt;/span&gt;
         &lt;span class="nv"&gt;test&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;FALSE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
      &lt;span class="nv"&gt;END_IF&lt;/span&gt;      
   &lt;span class="nv"&gt;END_FOR&lt;/span&gt;      
         
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Is there a solution to do it?&lt;/p&gt;
&lt;p&gt;Thank you for help&lt;br/&gt;
Luca&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>