8 Replies Latest reply on Mar 17, 2011 4:30 PM by philmodjunk

    wildcards

    HB

      Title

      wildcards

      Post

      Ok , now I really feel like a tool

      Why doesn't the following result as true

      "as"="a@"

      Doesn't @ replace any one character?????

      I've spent way too much time trying to do this simple little script!

      Inthe message box of a custom dialog box I am using the above formula in an if statement.

      Please help soon

      Thanks

        • 1. Re: wildcards
          philmodjunk

          The wild cards only apply to criteria entered for a find request. They are not used in calculations. In your boolean expression @ is just the @ symbol, there's no special wild card meaning that affects how the expression evaluates.

          • 2. Re: wildcards
            philmodjunk

            Not sure how you are trying to use this expression, but this would work where your @ won't"

            ( Left ( "as" ; 1 ) = "a" ) and ( Length ( "as" ) = 2 )

            • 3. Re: wildcards
              HB

              Thanks PhilModJunk - made my day.

              Wow - no availability of wildcards in a function?  Does FMP not see a real need for this????

              • 4. Re: wildcards
                philmodjunk

                How could you use that in expressions without making simple use of the same as literal text into complex expressions? Seems like we'd have to escape all kinds of different wild card operators in our text expressions if we did that.

                What kind of expression are you trying to set up that requires such wild cards? Usually, there's an alternative expression that can be used.

                • 5. Re: wildcards
                  HB

                  ya - I guess you are right - I was just trying my best to use the wildcard & was cinfused why it wasn't working! (coming from a VBA background)

                  • 6. Re: wildcards
                    philmodjunk

                    I've done a fair amount of VBA programming for MS Access systems also. While you can use wild cards in certain parts of an SQL expression, you can't use them in boolean expressions or other calculations in any other part VBA. Using wild cards in SQL is a pretty similar concept to using them in FileMaker find criteria.

                    It is possible to construct a custom function that uses wild cards in a text comparison. That might be very useful for certain types of data-entry validation. That idea intrigued me, so I took a shot at it. This is what I have so far. It uses @ and # wildcards much like you would in a find request. Haven't added * capability yet as that would complicate the process by quite a bit:

                    //WildcardMatch ( String ; Pattern )
                    // String   text to be matched against Pattern of text and wildcards
                    //Pattern  text pattern that combines literal text with @ and # used as wild cards

                    Let ( [ Ls = Left ( String ; 1 ) ;
                              Lp = Left ( Pattern ; 1 ) ;
                              Rstring = Right ( String ; Length ( String ) - 1 ) ;
                              Rpattern = Right ( Pattern ; Length ( Pattern ) - 1 ) ] ;
                             Case ( IsEmpty ( String  &  Pattern ) ; True ;
                                        ( Lp = "@" ) and not IsEmpty ( Ls ) ; True and WildCardMatch ( Rstring ; Rpattern  ) ;
                                        ( Lp = "#" ) and not IsEmpty ( Filter ( Ls ; 9123456780 ) ) ; True and WildCardMatch ( Rstring ; Rpattern  ) ;
                                        Lp = Ls ; True and WildCardMatch ( Rstring ; Rpattern  ) ;
                                        False
                                      )
                             )

                    • 7. Re: wildcards
                      HB

                      eh - thanks for looking at this for me -sounds doable - I am just pretty new at FMP & was reading about the wildcards as they are a tad different then in VBA. In my case the left() solution worked fine, as you suggested.  Actually I not made a custom function yet - don't you need advanced version for that?

                      • 8. Re: wildcards
                        philmodjunk

                        Yes, you need FileMaker Advanced to add custom functions to a file. (Once added, users with regular FileMaker can use them.)

                        I recommend you beg, borrow or steal the funds to upgrade to the advanced version. The script debugger alone is well worth the extra dollars (and should look fairly familiar to VBA programmers) as it can both teach you much about how scripts behave in FileMaker and also save you many many hours when figuring out why a script doesn't perform as expected.