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

22914Re: StrPosRight bug in NTP 7.0?

Expand Messages
  • flo.gehrke
    Jul 7, 2012
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "anachromat" <tim.peters@...> wrote:

      > > ^!Info ^$StrPosMid("X";"abcXdef";1;True)$
      > > ^!Info ^$StrPosMid("X";"abcXdef";2;True)$
      > >
      > > Different start positions are returning the same value.
      >
      > Ah, but I believe they _should_, right?

      Tim,

      Thanks -- you are certainly right.

      In my naive view, I thought that '^$StrPosMid$' is shifting the counting of string positions to the right, and the specified index position would be the point from where the COUNTING starts. Actually, it's the point from where the SEARCHING starts.

      Consequently...

      ^!Info Start at position #3 = ^$StrPosMid("X";"12345X7890";3;"1")$
      ^!Info Start at position #6 = ^$StrPosMid("X";"12345X7890";6;"1")$

      will correctly return the same value '6'. But...

      ^!Info Start at position #7 = ^$StrPosMid("X";"12345X7890";7;"1")$

      returns '0' because 'X' is not inside the range that is searched.

      I hope I learned the lesson now :-)

      Flo
    • Show all 17 messages in this topic