5 Replies Latest reply on Jan 10, 2016 5:03 PM by user19752

    String comparison (<= >=), how does that work ?

    planteg

      Hi,

       

      I went across to the Type-Ahead System demo from Nightwing (NightWing Enterprises - X4X - Type-Ahead System Demo for FileMaker Pro). It works pretty good, but there are a few things that I just can't understand).

       

      The relation that does the magic of filtering a portal is:

      Relation_1.jpg

      and the reference is defined as:

      Relation_2.jpg

      Question 1

       

      How the hell is it possible that this expression be true ?

       

      Question 2

       

      How is carried out these kinds of comparison between strings - by the way cSearch-Key is a list delimited by Enter. I just could find these comparisons documented.

       

      Many thanks, my head is aching over this .

        • 1. Re: String comparison (<= >=), how does that work ?
          beverly

          comparison is on the WHOLE string.

           

          'a' comes before 'aaa' (less than or equal to)

           

          Does that help?

           

          beverly

          • 2. Re: String comparison (<= >=), how does that work ?
            planteg

            Hi Beverly,

             

            I suddenly remembered how these comparison where done in Rexx !

             

            So if I am right for String1 compared to String2

            • if the length of String1 is less than then the length of Sting2, the String1 is less than String2
            • if both strings are of the same length and all characters match (case in not taken care off) then the strings are equal
            • in other cases where the strings are of the same length, comparison stops as soon as characters are not the same: is for last comparison the char in String1 is less that the one in String2 (char are compared for the same position), then String1 is less than String2

             

            Back to the demo database, the relation is used to filter the portal records. In this case:

             

            filter typed by user is "sh", transformed to "sh¶shzzzz"

            on of the record field is "Shirley Acevski", transformed to "AcevskiShirley Acevski"

             

            The two matches in the relation are evaluated to


            "sh¶shzzzz"  >= "AcevskiShirley Acevski"     1

            "sh¶shzzzz"  <= "AcevskiShirley Acevski"     0


            And that record is displayed ?!?!? How can 1 and 0 be 1 ?

            • 3. Re: String comparison (<= >=), how does that work ?
              user19752

              You are wrong at something.

               

              Length does not affect to string comparison priory, you know only when they are not equal then the strings are not equal.

               

              "all characters match" is the only need for the strings are equal, since if the length are not equal, all characters never match.

               

              On FM multi-key relationship, comparison is done on each line, not total string. Each line are compared to every line as "OR" criteria. So if both sides have 2 values in key, there are 2x2=4 comparison.

              In your example,

              "sh" >= "Acevski" then 1

              "sh" <= "Shirley Acevski" then 1

              (case sensitivity is depend on index language)

              • 4. Re: String comparison (<= >=), how does that work ?
                planteg

                On FM multi-key relationship, comparison is done on each line, not total string. Each line are compared to every line as "OR" criteria. So if both sides have 2 values in key, there are 2x2=4 comparison.


                Thanks for the tip, that explains why I got 'wrong' results when looking in Data Viewer. Were did you get that information ??? I looked into the advanced course material, googled that, never find that explanation.


                So now that I have the explanation, I tried doing the same in my own project, but that doesn't work . I am still missing something.


                EDIT


                I found a simpler method very similar ( I don't need to navigate the portal with cursor keys ). I think my issue was caused bay a calculation that was generating a number instead of a string . It's so simple to make such a mistake not realizing right away.


                • 5. Re: String comparison (<= >=), how does that work ?
                  user19752

                  It is written in note About match fields for relationships

                   

                  In the screenshot, relation is defined as

                  a >= b

                  AND

                  a <= b

                  so, if a = b then it is true, of course both field have one value, or any value is in both field.

                  There is at least one value in a which is greater than or equal to any value in b AND ... leaster ...

                  If a has 2  value and b has 1 value, it is true if b is between two values of a.