8 Replies Latest reply on Jun 29, 2013 1:32 AM by jrenfrew

    Why is this NOT Equal to that


      A repeating $$Variable containing "SA" in the third repetition


      If ( $$VARIABLE[3] = "SA" ; foo ; bar ) == bar NOT foo

      If ( PatternCount ( $$VARIABLE[3] ; "SA" ) ; foo ; bar ) == foo



      Any clues as to why??



        • 1. Re: Why is this NOT Equal to that

          Ignore my previous message, I messed up. 


          This could be true if $$VARIABLE[3] = "SAB" or "ZSA" or anything that has SA in it that is not exactly "SA"

          • 2. Re: Why is this NOT Equal to that

            But John said that the third repetition DID contain "SA", and was wondering why it would fail to validate.


            John, have you tried wrapping that to see if it's not pulling correctly, IE:

            If ( GetAsText( $$VARIABLE[3] ) = "SA" ; foo ; bar )


            I don't think GetField() is appropriate here, but have seen that used in similar problematic equations.

            • 3. Re: Why is this NOT Equal to that

              Don't you need quotes around the bar and foo?




              Ron Smith, MD, 'The Pediatric Guide For Parents'


              Want to know more about me and my family? Take a look at the free ebook about my daughter below.


              Forever And A Day For Laura Michelle

              • 4. Re: Why is this NOT Equal to that

                I think he was just trying to demonstrate his logic, not copy and paste straight out from FM. Yes you need quotes around returned text.

                • 5. Re: Why is this NOT Equal to that

                  I would confirm the value of that variable $$VARIABLE[3].


                  I suspect that you think $$VARIABLE[3] is "SA" when it actually is not.


                  Do a Show Custom Dialog with $$VARIABLE[3] prior to the test and confirm that it is what you think it is.



                  1 of 1 people found this helpful
                  • 6. Re: Why is this NOT Equal to that

                    Hi John


                    This problem is caused by the non-intuitive basics of repeating fields and is why many developers do not understand them.


                    The quick answer is that you must wrap the "SA" in the Extend() function. [Extend ("SA")].


                    In your calc, you are comparing the third row of $variable, with the third row of "SA" - which is empty. The Extend function will ensure that which ever row of "SA" is requested, then the result will be "SA".


                    In other words when doing comparisons of repeating fields, unless otherwise specified, the row counts all start from the first row.


                    Perhaps another way to look at it is to say;


                    If ( $$VARIABLE[3] = GetRepitition ( Extend("SA"); 3 ) ; foo ; bar ).


                    I must apologise for not being by my machine to test this - for example I don't know if Extend ( "SA" )[3] would work, but I have come across this issue in the past and what I am suggesting normally fixes it.


                    Best wishes - Alan Stirling, London UK.





                    Alan Stirling Technology Ltd, 135 Lisson Grove, London NW1 6UP

                    +44 (0) 20 7724 2456 - alan@ast.fm - www.ast.fm.

                    FileMaker Certified Developer for versions 7, 8, 9, 10, 11 and 12.

                    • 7. Re: Why is this NOT Equal to that

                      I don't think that's the case here. "SA" appears to be a literal text string, which does not require Extend(). If it were accurate then it's likely the PatternCount() test would fail too.


                      I just tested John's example. I set a variable $$VARIABLE[3] to "SA" by script, and in the Data Viewer, entered $$VARIABLE[3] = "SA" and the result was 1. Tested it with the If() and it returned the expected result.


                      Could there be a space or pilcrow in the $$VARIABLE[3]?

                      1 of 1 people found this helpful
                      • 8. Re: Why is this NOT Equal to that


                        Got it.


                        Did a Length ( $$VARIABLE[3] ) and discovered it was 6 and not 2...


                        The value is being stored as a choice from a from a magic value list using the ByteOrderMark trick to change the logical order - so of course


                        markmarkmarkmarkSA is not going to be "SA" in any world.


                        Thank you for letting me thing out loud.