<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Scan the bit of WORD variable</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/07cdd702ad/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/07cdd702ad/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/07cdd702ad/</id><updated>2020-02-27T13:50:32.505000Z</updated><subtitle>Recent posts to Scan the bit of WORD variable</subtitle><entry><title>Scan the bit of WORD variable</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/07cdd702ad/?limit=25#1fe0" rel="alternate"/><published>2020-02-27T13:50:32.505000Z</published><updated>2020-02-27T13:50:32.505000Z</updated><author><name>fpin</name><uri>https://forge.codesys.com/u/fpin/</uri></author><id>https://forge.codesys.comaffb8b2ffe6843a32d51e814b5be644af95870d0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;OK,&lt;br/&gt;
it was a good input.&lt;/p&gt;
&lt;p&gt;I found the function "EXTRACT" from the util library so I can do what I want.&lt;/p&gt;
&lt;p&gt;Thx&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Scan the bit of WORD variable</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/07cdd702ad/?limit=25#e067" rel="alternate"/><published>2020-02-27T13:50:32.343000Z</published><updated>2020-02-27T13:50:32.343000Z</updated><author><name>josepmariarams</name><uri>https://forge.codesys.com/u/josepmariarams/</uri></author><id>https://forge.codesys.com44414d2e6bfe022cfc2aef330c3b71aae3c53fec</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;do:&lt;/p&gt;
&lt;p&gt;if((wordVar and rlc(16h1,i))&amp;lt;&amp;gt;0)then ....&lt;/p&gt;
&lt;p&gt;Rlc moves the settted bit (1) i positions..&lt;br/&gt;
I don t remember the instruction name exactly, possibly rlc moves the bit to right and you want to move to left... Look at online help to find the exact instruction&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Scan the bit of WORD variable</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/07cdd702ad/?limit=25#58c7" rel="alternate"/><published>2020-02-27T13:50:32.141000Z</published><updated>2020-02-27T13:50:32.141000Z</updated><author><name>fpin</name><uri>https://forge.codesys.com/u/fpin/</uri></author><id>https://forge.codesys.comcc008280ecc291c40868defa2ff1e38db634a7ca</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi to the forum,&lt;/p&gt;
&lt;p&gt;someone knows how I can scan the bits of one WORD variable?&lt;/p&gt;
&lt;p&gt;For example:&lt;br/&gt;
I have the WORD variable that contains the axes mask (1=axle X, 2=Y, 3=XY, 4=Z and so).&lt;br/&gt;
Now I want to take this variable and analyze it to know how many axes I have to move, so I have to see each bit of the WORD and see if it is TRUE or FALSE.&lt;/p&gt;
&lt;p&gt;I saw that I can refer to the specific bit with the instruction:&lt;/p&gt;
&lt;p&gt;IF myAxesMask.0 THEN&lt;br/&gt;
    AxesToMove := AxesToMove + 1;&lt;br/&gt;
END_IF&lt;/p&gt;
&lt;p&gt;But in this way I have to do 16 of this instructions.&lt;/p&gt;
&lt;p&gt;My idea was to do something like that:&lt;/p&gt;
&lt;p&gt;FOR i := 0 TO 15 DO&lt;br/&gt;
    IF myAxesMask.i THEN&lt;br/&gt;
        AxesToMove := AxesToMove + 1;&lt;br/&gt;
    END_IF&lt;br/&gt;
END_FOR&lt;/p&gt;
&lt;p&gt;Unfortunately this won't be acepted by the compiler.&lt;br/&gt;
Someone knows is there is a "clean" solution similar with the FOR instruction?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>