1 Reply Latest reply on Feb 8, 2013 8:36 AM by philmodjunk

    Recursive Custom Function Returns "?"

    StevenBrown

      Title

      Recursive Custom Function Returns "?"

      Post

           Hi all,

           I am writing a FileMaker custom function that determines if a word exists in a value list. Some elements in the list match with a trailing wildcard character ("*"), whereas others are exact matches. The function is returning a "?" but I cannot determine why. Any help is greatly appreciated!

            

      // Function takes two parameters: word and dictList (value list of words)
      Let (
      [
           libRawWord = Substitute(LeftValues( dictList ; 1); "¶" ; "");
                      libRawWord = Substitute(LibRawWord; " "; "");
           isWildCard = Right( libRawWord ; 1 ) = "*";
           libRefWord =
                Case
                (
                     isWildCard ; Left ( libRawWord; Length(libRawWord)-1 ) ;
                     libRawWord
                );
           isMatch = Case( isWildCard ; Position(word ; libRefWord ; 1 ; 1) = 1 ;
                                                Exact( libRefWord ; word) = 1);
           dictList = RightValues ( dictList ; ValueCount(dictList) - 1 )
      ];
           Case
           (
                isMatch ; True ; // Should be true, just testing...
                not IsEmpty(dictList) ; IsMatchedWord( word ; dictList );
                False
           )
      )

            


           Interestingly, if I change the definition of isMatch to Position(word ; dictList ; 1 ; 1) = 1, the code executes without a problem (although not with the functionality I want).

        • 1. Re: Recursive Custom Function Returns "?"
          philmodjunk

               I copied and pasted the above custom function text into Filemaker Pro Advanced 12 on a Windows XP machine and tested a number of different words and word lists, both with and without wildcard entries.

               each time, I got the expected 1 (true) or 0 (false) result.

               ps. While it makes no difference on the results returned, you can simplify part of your expression by using getValue instead of LeftValues:

          libRawWord = Substitute(GetValue( dictList ; 1); " " ; "")

          instead of:

          libRawWord = Substitute(LeftValues( dictList ; 1); "¶" ; "");
                   libRawWord = Substitute(LibRawWord; " "; "");