Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Compare structures

switcher
2014-11-19
2014-11-27
  • switcher - 2014-11-19

    Hi,

    How can we compare two structures between them?
    I mean compare values of structure 1 members EQUAL to values of structure 2 members, like IF STRUCTURE 1 = STRUCTURE 2 THEN....

    Thank you.
    Best regards,
    Zdenko.

     
  • Anonymous - 2014-11-20

    Originally created by: scott_cunningham

    You use pointers and compare each byte of the first with the second. See BUFFER_COMP in the OSCAT library for a free, already existing function. Otherwise you can make your own. SIZEOF() will tell you how many bytes to compare.

     
  • switcher - 2014-11-20

    Thank you Scott,
    I already implemented this as you suggested. It works fine.

    Best regards,
    Zdenko.

     
  • TimvH

    TimvH - 2014-11-27

    In the memory library is a function "compare".
    This uses 2 pointers to memory blocks.
    If the result is 0, they are the same, otherwise the return value refers to the first byte where the difference is.

     

Log in to post a comment.