5 Replies Latest reply on May 9, 2013 1:31 PM by DavidJondreau

    Difference between two variables

    strngr12

      Hello,

       

      I need to be able to run the contents of a field through a filter that strips out characters that are illegal in a 3rd party xml and return a dialogure that tells the user what the bad character is. Right now what I am doing is setting a variable $variableBefore = Count ( field ) the I run it through a filter that contains all acceptable characters. I then take the results of that filter and set a variable $variableAfter = Count ( ScriptResult ). Then I ask, if $variableBefore > $variableAfter Custom Dialoge [ There is an illegal Charater... blah, blah, blah ] I want to compare:

       

      $variableBefore & $variableAfter

       

      So I can see what the difference is so i ca alert the user as to what the bad character is.

       

      Can anyone help?

       

      Thanks,

       

      Dan

        • 1. Re: Difference between two variables
          sporobolus

          on 2013-05-09 12:54 strngr12 wrote

          Right now what I am doing is setting a variable $variableBefore = Count ( field ) the I run it through a filter that contains all acceptable characters.  I then take the results of that filter and set a variable $variableAfter = Count ( ScriptResult ).  Then I ask, if $variableBefore > $variableAfter Custom Dialoge   I want to compare:

           

          here is an interesting method that uses a webviewer to get the benefits of

          JavaScript text functions

           

          <http://www.goya.com.au/blog/performing-diff-comparison-2-text-fields-filemaker

          • 2. Re: Difference between two variables
            strngr12

            Thanks, but filter leaves all the legal stuff in and doesn't return illegal stuff.  For example, if I start with abcdef! and the ! is illegal, then I finish with abcdef.

             

            If I then filter abcdef! through abcdef I get abcdef, again.  That doesn't tell me what the bad character was.

             

            What I'm looking for is something that will return the ! so I can throw a dialogue up that says, "Hey, user, you can't use ! in your field values."

            • 3. Re: Difference between two variables
              strngr12

              Sorry, the above reply was for an answer that appears to have been withdrawn.

               

              I looked at your answer and I'm not aure that's portable enough.  I need to zip these documents up and send them out to people in a variety of enviornments and no connection to the internet or to our servers.

              • 4. Re: Difference between two variables
                sporobolus

                on 2013-05-09 13:24 strngr12 wrote

                I looked at your answer and I'm not aure that's portable enough.  I need to zip these documents up and send them out to people in a variety of enviornments and no connection to the internet or to our servers.

                 

                shifting goalposts … then why not make a PDF of the web viewer display? if

                that's not suitable, a script could copy and paste the web viewer content to a

                suitable text editor (works with TextEdit on OS X, but the formatting goes

                slightly wonky

                 

                for a plain text comparison you could send the two files through a proper diff

                (e.g. in OS X shell, but Windows must have something)

                • 5. Re: Difference between two variables
                  DavidJondreau

                  Count() is not the function you're looking for. I think you want to use Length().

                   

                  But that won't really give you the answer. If you have FM Advanced, use something like this custom function the acts like a reverse filter.

                  1 of 1 people found this helpful