<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Compare array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/83c63a47c7/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/83c63a47c7/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/83c63a47c7/</id><updated>2020-02-27T13:51:01.568000Z</updated><subtitle>Recent posts to Compare array</subtitle><entry><title>Compare array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/83c63a47c7/?limit=25#b349" rel="alternate"/><published>2020-02-27T13:51:01.568000Z</published><updated>2020-02-27T13:51:01.568000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com674a6b4095f9b23c7c3c9e1478e7fca57f87f755</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; KevinR&lt;/p&gt;
&lt;p&gt;Hello NBCC,&lt;/p&gt;
&lt;p&gt;check out the CAA Memory Library. There is a Compare function under the category "CAA_Memory" --&amp;gt; "Analysis" --&amp;gt;"ARRAY and MemoryBlock". With this function you can compare arrays and find the first position of the change. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;wPosition&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;MEM&lt;/span&gt;.&lt;span class="nv"&gt;Compare&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;arrArray1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,&lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;arrArray2&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,&lt;span class="nv"&gt;SIZEOF&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;arrArray1&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;wPosition&lt;/span&gt; &lt;span class="o"&gt;&amp;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="c1"&gt;; // difference on position X&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Regards,&lt;br/&gt;
KevinR&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Compare array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/83c63a47c7/?limit=25#9dd7" rel="alternate"/><published>2020-02-27T13:51:01.128000Z</published><updated>2020-02-27T13:51:01.128000Z</updated><author><name>NBCC</name><uri>https://forge.codesys.com/u/nbcc/</uri></author><id>https://forge.codesys.comfe2016a3a1ee543253a7b2085221adc59d177c84</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks for the reply  I'll work on it&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Compare array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/83c63a47c7/?limit=25#909b" rel="alternate"/><published>2020-02-27T13:51:01.005000Z</published><updated>2020-02-27T13:51:01.005000Z</updated><author><name>teichhei</name><uri>https://forge.codesys.com/u/teichhei/</uri></author><id>https://forge.codesys.com3225536f54aba6f3558a95702cca6080d8d0a096</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You can also leave the codes as an Array of string and use oscat basic Chr_to_string and concat in a loop to build your string from bytes. Or you do a pointer to string with an address of aByte&lt;span&gt;[0..79]&lt;/span&gt; and load your four bytes into &lt;span&gt;[0..3]&lt;/span&gt; and make sure the rest stays 0. Then it's flexible with the lenght as well.&lt;/p&gt;
&lt;p&gt;Sent from my SM-G935F using Tapatalk&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Compare array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/83c63a47c7/?limit=25#83b5" rel="alternate"/><published>2020-02-27T13:51:00.883000Z</published><updated>2020-02-27T13:51:00.883000Z</updated><author><name>NBCC</name><uri>https://forge.codesys.com/u/nbcc/</uri></author><id>https://forge.codesys.comb0446bc0cae58251b84941d43af0d9bc5fe0c528</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;teichhei hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Hi,&lt;br/&gt;
I would stick the codes into an array of dwords, a pointer to dword to the 4 bytes that come from the scanner and then a for loop to look through the array to see if you find a match.&lt;br/&gt;
Heinz&lt;br/&gt;
Sent from my SM-G935F using Tapatalk&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I could check that&lt;br/&gt;
Do you know if it is possible by converting it into a string or whatever? It could be easy to know when i have to work on other projects if there are more bytes.&lt;br/&gt;
Thanks in advance&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Compare array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/83c63a47c7/?limit=25#1985" rel="alternate"/><published>2020-02-27T13:51:00.759000Z</published><updated>2020-02-27T13:51:00.759000Z</updated><author><name>teichhei</name><uri>https://forge.codesys.com/u/teichhei/</uri></author><id>https://forge.codesys.com153c3dfb104c74ff9af17ed3438d68b36918610a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I would stick the codes into an array of dwords, a pointer to dword to the 4 bytes that come from the scanner and then a for loop to look through the array to see if you find a match.&lt;/p&gt;
&lt;p&gt;Heinz&lt;/p&gt;
&lt;p&gt;Sent from my SM-G935F using Tapatalk&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Compare array</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/83c63a47c7/?limit=25#260f" rel="alternate"/><published>2020-02-27T13:51:00.634000Z</published><updated>2020-02-27T13:51:00.634000Z</updated><author><name>NBCC</name><uri>https://forge.codesys.com/u/nbcc/</uri></author><id>https://forge.codesys.comb4ac98fddea2d703b3472b5bd386abe2da17b366</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi all.&lt;br/&gt;
I am new to codesys but I am getting the hang of it. I only struggle with the arrays. Now i need to do some actions with arrays and i have no idea how to start.&lt;br/&gt;
Here's the situation:&lt;br/&gt;
I want to put 50 codes into the plc (these will never change). When someone scans an article, a code is given in the plc with an "array &lt;span&gt;[0..3]&lt;/span&gt; of byte".&lt;br/&gt;
Now I want to compare this result with the 50 other codes. All codes are the same length. &lt;br/&gt;
But i have no idea how to compare the array of byte with the codes. How to convert the array to a string? Or are there other options? Does anyone knows a solution with this problem?&lt;br/&gt;
All has to be done in ST btw &lt;/p&gt;
&lt;p&gt;Many thanks.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>