Moggie Posted June 28, 2007 Report Posted June 28, 2007 Is there a FC/FB that can help me with the following? I need to search a DB for data, when the first instance of that data is found I want to know what DBB that data is in? Thanks in advance. Quote
JesperMP Posted June 28, 2007 Report Posted June 28, 2007 (edited) With "DBB" you mean at which byte number the match is found ? It would be dead simple with SCL. It is still possible with STL, here is an attempt (not tested): OPN "Data_Ind" //Open data block L P#0.0 T "D_Pointer" //Pointer to the start of the data field L #Quantity_Data Next: T #LoopCounter L #ComparisonValue L DBB ["D_Pointer"] =I //Notice. There is no //instruction for comparing bytes, //so integer compare is used. = "Match_found" A "Match_found" JC _OUT //stop looping when a match is found. L "D_Pointer" + 8 //Increment data field pointer by 1 bytes T "D_Pointer" L #LoopCounter LOOP Next //Jump back to start of loop _OUT: NOP 0 When a match is found then subtract LoopCounter from Quantity_Data to obtain the byte number. Edited June 28, 2007 by JesperMP Quote
Groo Posted June 29, 2007 Report Posted June 29, 2007 There is a standard FB, I don't have S7 at the mo, so can't remember the name, I think it was something like FIND. I'll see if I can download the standard library manual. Quote
Groo Posted June 29, 2007 Report Posted June 29, 2007 FC86, I believe it can be found in the S5 to S7 conversion library. I have used it once before and wirked well. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.