Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Tips and Techniques: Compare and Ignore Case

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tips and Techniques: Compare and Ignore Case

    ** This thread discusses the article: Tips and Techniques: Compare and Ignore Case **
    ** This thread discusses the Content article: Tips and Techniques: Compare and Ignore Case **
    0

  • #2
    Tips and Techniques: Compare and Ignore Case

    ** This thread discusses the article: Tips and Techniques: Compare and Ignore Case **
    Er, don't you have to use %addr() for the first two parameters...?

    Comment


    • #3
      Tips and Techniques: Compare and Ignore Case

      ** This thread discusses the article: Tips and Techniques: Compare and Ignore Case **
      You're right. You have to use %ADDR(var). if the variable is a varying field, then use %addr(var)+2. I think in my examples I 'tricked' the compiler into converting to null terminted strings, by adding OPTIONS(*STRING) to the first two parameters on the memicmp prototype. That way, you can avoid the %addr() requirement. -BOb
      Code

      Comment


      • #4
        Tips and Techniques: Compare and Ignore Case

        ** This thread discusses the article: Tips and Techniques: Compare and Ignore Case **
        Wouldn't that return an offset of Zero..... and how would that be distinguished from the "equal ignoring case" condition ??

        Comment


        • #5
          Tips and Techniques: Compare and Ignore Case

          ** This thread discusses the article: Tips and Techniques: Compare and Ignore Case **
          You only need to add 2 to the address ( %addr(var)+2 ) if the field is varying length. For a fixed length field it's just %addr(var).

          Comment


          • #6
            Tips and Techniques: Compare and Ignore Case

            ** This thread discusses the article: Tips and Techniques: Compare and Ignore Case **
            Phil, Were you answering my question ?? What I was saying, regardless of whether it's a Var or fixed length field, is that it sounds like, based on Bob's explanation, that if there were a difference in the first position of the Data, the function would return 0 as the offset and if the two strings were equivalent the function would also return zero. So how would we ever know if the two strings were really equivalent ?? Mike

            Comment


            • #7
              Tips and Techniques: Compare and Ignore Case

              ** This thread discusses the article: Tips and Techniques: Compare and Ignore Case **
              Mike: When in doubt, you can look up things in Google. A Google search on "memicmp" turned up a libc.a reference page that describes memicmp() in a bit more detail. Basically, it works like memcmp() in that it returns 0 if the strings are equal, 1 if the first string is greater than the other, and -1 if the first string is less than the other. Also note, for what it's worth, that memicmp() is neither ANSI nor POSIX compliant. Cheers! Hans

              Comment


              • #8
                Tips and Techniques: Compare and Ignore Case

                ** This thread discusses the article: Tips and Techniques: Compare and Ignore Case **
                I know, I know..... RTFM. But I thought if I hung out here, I wouldn't have to. ;-) Thanks, Hans. That answer makes sense.

                Comment

                Working...
                X