2 Replies Latest reply on Jun 24, 2012 4:27 PM by olafseifert

    Function "Position ()" computes not like I would

    olafseifert

      Hi everybody,

       

      first, I found a workaround for my problem, which I do like much more than my first attempt to reach the following:

       

      Think of a text field, named "index", containing strings like "1.1.4.5" or "2.12.3". My goal was to extract parts of the string - the second segment, for instance (here: "1" or "12", respectively) by letting data being calculated in a second field. With this ("ZeichenMitte" is German for "Middle"):

       

      index_segment2 = ZeichenMitte ( index ; Position ( index ; "." ; 1 ; 1 ) + 1 ; Position ( index ; "." ; 1 ; 2 ) - 1 )

       

      the results are "1.4" and "12.3" - FileMaker didn't took the second but the third appearance of the dot. I thought, FileMaker got confused calculating the position of the same text two times in only one formula. Perhaps, its count for the appearance during the runtime of the calc might be shifted by 1? I tried this:

       

      index_segment2 = ZeichenMitte ( index ; Position ( index ; "." ; 1 ; 1 ) + 1 ; Position ( index ; "." ; 1 ; 1 ) - 1 )

       

      and got "1" in both cases.

       

      Obviously, this was no good approach. I did it this way, and it works fine:

       

      1. Converting the data in "index" into a new formula field while using the function "Austauschen ()" ("Substitute () ") to change every dot into a space character.

      2. Finally, using "WörterMitte ()" ("MiddleWords ()") to get the second segment of the new field with the converted data.

       

      But, what is wrong with my understanding of "Position ()"?

       

      Regards from Hamburg,

      Olaf