Jump to content

Recommended Posts

Posted
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.
Posted (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 by JesperMP
Posted
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.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...