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

Unexpected results for IfSame

Expand Messages
  • joy8388608
    NTP 7.1 I am getting unexpected results for IfSame by adding and removing sets of double quotes. I do not see the pattern. Place the following lines in a
    Message 1 of 5 , Jan 16, 2014
    • 0 Attachment

      NTP 7.1


      I am getting unexpected results for IfSame by adding and removing sets of double quotes. I do not see the pattern.


      Place the following lines in a document. Blank lines are ignored. Place an X in col 1 after the data lines.


      Run the code.


      My results are shown after the code.


      Any ideas?


      Joy



      "_options1=/XD .dropbox.cache C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog)" /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP"


      "_options1=/XD .dropbox.cache "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE" C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog) /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP"


      _options1=/XD ".dropbox.cache" C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog) /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


      _options1=/XD ".dropbox.cache" "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE" C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog) /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


      _options1=/XD .dropbox.cache "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE" "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog)" /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


      _options1=/XD .dropbox.cache "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE" "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog)" /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


      X


      ^!SetWordWrap OFF

      ^!Set %I%=0


      :LoopTop

      ^!Inc %I%

      ^!Set %Value%=^$Getline(^%I%)$

      ^!IfSame "^$StrCopyLeft("^%Value%";1)$" "X" END

      ^!If ^$StrSize("^$StrTrim("^%Value%")$")$=0 LoopTop

      ^!IfSame "^%Value%" "^%Value%" 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%^%NL%

      ^!Goto LoopTop


      My Results

      -----------

      MATCH _options1=/XD .dropbox.cache C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog)" /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


      MATCH _options1=/XD .dropbox.cache "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE" C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog) /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


      MATCH _options1=/XD ".dropbox.cache" C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog) /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


      NO MATCH _options1=/XD ".dropbox.cache" "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE" C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog) /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


      NO MATCH _options1=/XD .dropbox.cache "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE" "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog)" /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


      NO MATCH _options1=/XD .dropbox.cache "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\ADD FILES HERE" "C:\Users\Fred\Desktop\Dropbox\ASSeRT Lab\Articles (make catalog)" /LOG+:%BkUpLogLoc%\BKUPLOG_%TodayYYYYMMDD%.txt /TEE /NP


    • ebbtidalflats
      Joy, Did your code not generate a function syntax error? You re testing the first character of value, before testing if the line is empty. ... ^!Set
      Message 2 of 5 , Jan 19, 2014
      • 0 Attachment
        Joy,

        Did your code not generate a function syntax error?

        You're testing the first character of value, before
        testing if the line is empty.

        ...
        ^!Set %Value%=^$Getline(^%I%)$
        ^!IfSame "^$StrCopyLeft("^%Value%";1)$" "X" END
        ^!If ^$StrSize("^$StrTrim("^%Value%")$")$=0 LoopTop
        ...

        This should generate a syntax error, when value is empty.
        Perhaps this is a bug in NoteTab.


        Cheers,

        Eb
      • joy8388608
        There were no errors. The bug you are speaking of is only a bug if doing a StrCopyLeft on an empty value should be invalid. The specs (I mean HELP file) do not
        Message 3 of 5 , Jan 20, 2014
        • 0 Attachment

          There were no errors. The bug you are speaking of is only a bug if doing a StrCopyLeft on an empty value should be invalid. The specs (I mean HELP file) do not specify this so it's technically not a bug... it simply does not return an "X" so the IFSAME returns FALSE.


          Anyway, this is not the problem. Just remove the blank lines in the data to make the above issue moot.


          I still have IfSame returning FALSE when comparing a value to itself just by changing a set of double quotes.


          Has anyone else run this test and seen this or something different?


          Joy

        • joy8388608
          I couldn t stand the suspense and found the pattern. When there are zero or one quoted items in a string ex: This string has zero quoted items This string has
          Message 4 of 5 , Jan 20, 2014
          • 0 Attachment

            I couldn't stand the suspense and found the pattern.


            When there are zero or one quoted items in a string


              ex: This string has zero quoted items

                    This string has "one" quoted item


            IfSame works correctly.


            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.


            This qualifies as a bug to my way of thinking. Does anyone else see it differently?


            Joy


            Data

            ------

            00N_options1=cache C:\Users C: /LOG

            "00Q_options1=cache C:\Users C: /LOG"

            01N_options1="cache" C:\Users C: /LOG

            "01Q_options1="cache" C:\Users C: /LOG"

            02N_options1="cache" "C:\Users" C: /LOG

            "02Q_options1="cache" "C:\Users" C: /LOG"

            03N_options1="cache" "C:\Users" "C:" /LOG

            "03Q_options1="cache" "C:\Users" "C:" /LOG"

            x


            Results

            ----------

            MATCH 00N_options1=cache C:\Users C: /LOG

            MATCH 00Q_options1=cache C:\Users C: /LOG

            MATCH 01N_options1="cache" C:\Users C: /LOG

            MATCH 01Q_options1="cache" C:\Users C: /LOG

            NO MATCH 02N_options1="cache" "C:\Users" C: /LOG

            NO MATCH 02Q_options1="cache" "C:\Users" C: /LOG

            NO MATCH 03N_options1="cache" "C:\Users" "C:" /LOG

            NO MATCH 03Q_options1="cache" "C:\Users" "C:" /LOG


            ^!SetWordWrap OFF

            ^!Set %I%=0


            :LoopTop

            ^!Inc %I%

            ^!Set %Value%=^$Getline(^%I%)$

            ^!IfSame "^$StrCopyLeft("^%Value%";1)$" "X" END

            ;^!If ^$StrSize("^$StrTrim("^%Value%")$")$=0 LoopTop

            ^!IfSame "^%Value%" "^%Value%" 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


          • flo.gehrke
            ... 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
            Message 5 of 5 , 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
            Your message has been successfully submitted and would be delivered to recipients shortly.