4/26/2011 6:11 PM | |
Posts: 2348 Rating: (264)
|
Well, place the new version of code here - can check it:^) |
4/27/2011 8:53 AM | |
Joined: 10/7/2005 Last visit: 10/4/2024 Posts: 3024 Rating: (1054)
|
Hello Matilda The following twothings stick out in your logic: 1.) The command "A DB130.DBX1.0" will open DB 130 which - once executed - will stay open for the rest of the loop since DB200 is opened outside the loop. 2.) You increment AR1 by only 1 byte from one loop to the next but do access WORD variables via "L DBW [AR1,P#0.0]" which doesn't make too much sense to me(I'dexpect to see AR1 incresed by 2 Bytes per loop). Anyhow, below is my idea of your logic (not tested, so please try for yourself if it gives you the result you are after): LAR1 P#0.0 L 100 loop: T MW20 OPN DB200 // Open DB 200 L DBW [AR1,P#0.0] //Comparisons start L W#16#3136 ==I JCN _001 A DB130.DBX1.0 // DB130 is opened! _001: NOP 0 //Comparison ends +AR1 P#2.0 // bump AR1 by 2 Bytes to point to the next WORD L MW20 LOOP loop Notes: - DB200 must be at least 200 Bytes (100 Words) long. - Make sure that the logic between Comparison start and end does NOTchange AR1 (see HERE for more). - I prefer touse a TEMP variable for the Loop counter instead of MW20 (but either will work) I hope this helps |
Cheers |
|
This contribution was helpful to1 thankful Users |
4/28/2011 11:55 AM | |
Joined: 10/7/2005 Last visit: 10/4/2024 Posts: 3024 Rating: (1054)
|
MM1234's is correct (thanks MM1234),I did neglect to read thefollowing requirement from your orignal post: "The data in db is in 'CHAR' datatype and theres 100 bytes of content. But I need to look for 2 CHAR at the same time" In that case, do only"+AR1 P#1.0" to bump AR1 by one byte and do only 99 Loops. Having said that, if you were to copy your array of CHAR's into another DB and add thetwoString header bytesbefore it(max lenght and actual lenght, make both 100), you couldusethe IEC "FIND" String Function (default number is FC11 in the IEC library) to "find" the position of your search String within the main String (food for thougth anyhow which may come in handy in the future). |
Cheers |
|
This contribution was helpful to1 thankful Users |
5/6/2011 8:31 AM | |
Posts: 53 Rating: (1) |
Thanks guys for your help! |
This contribution was helpful to3 thankful Users |
Follow us on