search for duplicates

david.hinch

Member
Join Date
Aug 2018
Location
merlin
Posts
2
RSLogix 5000

Need to search a 600 point string array for matching numbers, eg: SPRD(0) to SPRD(599)

If I have 2 part numbers the same then set a bit high.
 
Do a compare and index both inputs. Index thefirst from 0 to 1,2,3 etc. When you reach 600 infrx the second from 0to 1 and rerun the 1st instance. Once complete index from 1to 2
 
RSLogix 5000

Need to search a 600 point string array for matching numbers, eg: SPRD(0) to SPRD(599)

If I have 2 part numbers the same then set a bit high.

Could these part numbers be stored as DINT values, or too many digits and/or embedded non-digits?

If you can put them in a DINT array, it would be more efficient to sort and then scan the array once; not to mention a DINT compare vs. string compare.

If not, then carefully consider whether the nested looping should be done all in one scan, or spread over multiples.
 
Fsc

You can use FSC to compare a array against itself with a bit of work. I had to make sure the .POS and the Index tag weren't the same else you would find a match since you would be comparing itself against itself.

If you increase the .POS by 1 past the index you don't get a match and it would speed it up so your not re comparing data for a second time. [3 vs 5] then [5 vs 3] later on.

This way the first compare is [0 vs 1-19] and then the next compare is [1 vs 2-19] etc. till [17 vs 18-19] etc. I did a 20 array so I wouldn't have to hand enter data into 600 array.

Compare Array.PNG Compare Array Data.PNG
 
You can use FSC to compare a array against itself with a bit of work. I had to make sure the .POS and the Index tag weren't the same else you would find a match since you would be comparing itself against itself.

This clever approach has the feature of working over multiple scans. Therefore it might be advisable to copy the string array into a working copy for the FSC before starting, in case the base array could change while duplicate-checking. Otherwise prevent any changes while this logic is running.

One thing I did not see, and it could be below the rungs in the screen shot, is handling the situation where there are no duplicates. It appears that the processor would eventually fault on an out-of-bounds index in this case.
 
The original code had a move zero to index when it reached the size of the array. That had gotten dropped out when I built this. Also how I had this set up it stops once it finds its first match. You can have it pause and move the .pos and index to a array to create a list of matches. Then unlatch the required tag and have it start back up.
 

Similar Topics

Searching edit zones within all routines and other criteria still says no results found, yet I still have the "edits present" indicator at the...
Replies
6
Views
253
I have an InTouch HMI that has PID parameters. I need to find what the PID values were in the past. I have backups from the past, but none...
Replies
48
Views
5,546
Good morning folks, I'm on a quest to find all of the references to the CurrentUserHasCode function in our project. I have the project...
Replies
2
Views
430
Need to learn a few more tricks in Proficy Machine Edition. I don't use it often, but one of the first things I usually do when getting into a new...
Replies
3
Views
1,012
Hello all, Some of you may be familiar with the RAM searching program for Windows computers, Cheat Engine. You can search RAM directly for...
Replies
0
Views
737
Back
Top Bottom