Loading ...
Sorry, an error occurred while loading the content.

24315Re: Unexpected results for IfSame

Expand Messages
  • flo.gehrke
    Jan 21, 2014
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, <mycroftj@...> wrote:
      >
      > If there are two or more it does not match even though it should.
      > ex: This "string" has "two" quoted items
      > Surrounding the entire strings with double quotes does not make
      > a difference.

      Joy,

      I have to confirm your results but have no explanation why, in this case, two quoted items return "NO MATCH". Probably, NT has some problems to segment a string like that correctly.

      It's the same result when running your clip against data being more simple like...

      AAA BBB CCC DDD
      "AAA BBB CCC DDD"
      AAA "BBB" CCC DDD
      "AAA "BBB" CCC DDD"
      AAA "BBB" "CCC" DDD
      "AAA "BBB" "CCC" DDD"

      Strange enough, this doesn't happen in any case. For example...

      ^!IfSame "This "string" has "one" quoted item" "This "string" has "one" quoted item" MessTrue Else MessFalse
      :MessTrue
      ^!Info True
      ^!Goto End
      :MessFalse
      ^!Info False

      Why does this clip a return 'True'?

      I tested a work-around that removes inner quotes:

      ^!SetWordWrap OFF
      ^!Set %I%=0

      :LoopTop
      ^!Inc %I%
      ^!Set %Value%=^$Getline(^%I%)$
      ^!IfSame "^$StrCopyLeft("^%Value%";1)$" "X" END
      ; Remove inner quotes and assign string to ^%ValueNIQ%
      ^!Set %ValueNIQ%=^$StrReplace("(?!^\x22)(?!\x22$)\x22";"";"^%Value%";RA)$
      ^!IfSame "^%ValueNIQ%" "^%ValueNIQ%" IFSAMEMATCH else IFSAMENOTMATCH

      :IFSAMEMATCH
      ^!Set %Res%="MATCH"
      ^!Goto C1

      :IFSAMENOTMATCH
      ^!Set %Res%="NO MATCH"
      ^!Goto C1

      :C1
      ^!Jump Text_End
      ^!InsertText ^%Res%^%TAB%^%Value%^%NL%
      ^!Goto LoopTop

      When running this clip against your data I get a 'MATCH' for all eight lines.

      Regards,
      Flo
    • Show all 5 messages in this topic