8 Replies Latest reply on Feb 15, 2010 6:47 AM by LeoB

    Why can't I make If (IsEmpty) work according to the Function Reference guide?

    LeoB

      Title

      Why can't I make If (IsEmpty) work according to the Function Reference guide?

      Post

      The following is from the FMP10 Function Reference guide concerning the IsEmpty function:

       

      If (IsEmpty (LastName) ; “Invalid record” ; ““ ) displays Invalid Record if the LastName field is blank, but displays nothing if there is an entry in LastName.

       

      I have tried this every way but Sunday and cannot get it to work.  I keep getting the flash screen that it requires an operator.

       

      I want to have certain blank fields in a layout display some text as a prompt of what should be in the field, and then have the prompt disappear when the user starts typing into it.  This function looks perfect for that, but I seem to be missing something that is not explained in the Functions Reference guide.  I have used IfEmpty in a couple other scripts, and it has always been a single line without a lead in to identify the field, as that is included in the parentheses.

       

      Is it the ““ at the end?  I thought that could be inserted by clicking on what looks like that in the middle of the Specify Calculation screen.

       

      Thanks

       

       

       

        • 1. Re: Why can't I make If (IsEmpty) work according to the Function Reference guide?
          ninja
            

          Howdy LeoB,

           

          No answer, just a question:

           

          If you were to write it as If (LastName = "" ; “Invalid record” ; ““ )

          do you then get what you are after?

           

          My question is "Is it the use of IsEmpty, or something else...like invisible stuff in the LastName field?"

           

          • 2. Re: Why can't I make If (IsEmpty) work according to the Function Reference guide?
            LeoB
              

            Ninja:

             

            Doesn't work.  I get the same flash screen that an operator is expected here.

             

            Are the types if quotation marks used important?  I noticed that in the example from the FMP Reference Guide and in your message there are three different types of marks used.

             

            Standard slanted quotation marks are around the text to be inserted,the first set of double quotes are perpendicular, and the last set of double quotes are both slanted from top left to bottom right (like a blackslash).

             

            Thanks

            • 3. Re: Why can't I make If (IsEmpty) work according to the Function Reference guide?
              ninja
                

              LeoB wrote:

              I get the same flash screen that an operator is expected here.

              Kill the field, make a new one and type your If statement in again, using only the """" key for quotes. 

               

              Are the types if quotation marks used important?  I noticed that in the example from the FMP Reference Guide and in your message there are three different types of marks used.

              I don't think so, but I've never had the problem you describe either.  That's why I would kill the field and start over.  It's a simple calculation, easy to simply start over from scratch.

               

              Make sure that you uncheck the "Do not evaluate" button on the bottom, and make sure your calculated result is set to text.

               


              Does that solve the problem?


              • 4. Re: Why can't I make If (IsEmpty) work according to the Function Reference guide?
                LeoB
                  

                Well, bad news and good news.

                 

                Bad news is I still cannot get it to work.  I put the field on a blank layout and tried to write the script for there.  But if I insert the parentheses (even though there are only two) the flash screen says one is missing.  Without the parentheses, it highlights

                 

                ; “Invalid record” ; ““

                 

                and says that an operator is missing.

                 

                The good news is I found a workaround.  I just said if the field is empty, then went to the next line and said insert text.  Works fine.

                 

                The FMP documentation, however, does not impress me.  That's why this forum is so important.

                 

                Thanks

                • 5. Re: Why can't I make If (IsEmpty) work according to the Function Reference guide?
                  ninja
                    

                  Whoa,


                  LeoB wrote:

                   

                   I just said if the field is empty, then went to the next line and said insert text.  Works fine.


                   

                  Is this in a script?  I don't see anything above that said it was in a script.  I assumed it was in a calculation field.  It should be in a calculation field, NOT a script.

                   

                  Please confirm.


                  • 6. Re: Why can't I make If (IsEmpty) work according to the Function Reference guide?
                    LeoB
                      

                    Ninja:

                     

                    Whoops.  My bad, as I've heard on TV.

                     

                    Yes, it was in a script to be run on OnRecordLoad.

                     

                    When a record is loaded with certain blank fields (both a new record or an existing record) I was trying to write this little scipt to insert some text for guidance.  Then the user would replace it with inserted text.  I've gone through the documentation and was trying to figure out of it could insert the highlighted text like in some WIndows field that would automatically disappear when you start typing in the field, but can't find anything like that.

                     

                    It was not a calculation field.  In fact, I have no calculation fields at all as this database is not about numbers anywhere.

                     

                    Sorry for the confusion.

                     

                    Thanks

                    • 7. Re: Why can't I make If (IsEmpty) work according to the Function Reference guide?
                      ninja
                        

                      Well,  That's why it wasn't working.  The syntax I was offering was for a calculation field.

                       

                      For a script, you would use something like:

                       

                      If (IsEmpty (LastName) )

                          SetField (LastName ; "Invalid Record" )

                      EndIf

                       

                      Note: You are checking a field, then changing it's contents.  If you check the field and find something in the LastName field, I figure you want to leave it alone.

                      Note futrther: If you visit this record, and set the field to "Invalid Record"...it won't be empty anymore.

                       

                      You may want to take another approach:

                      Make a field "Flag1" which is a calculation field (not scripted ;) )

                      Set it to If(IsEmpty (LastName) ; "Invalid" ; "" ) and put it in large red text as a popup flag.  If everything is OK, it will be blank.  If there's something wrong, it will show the warning.

                       

                      At the very least, conditionally format the "Invalid" text to draw the users eye to it.

                       

                      Hope this helps!

                      • 8. Re: Why can't I make If (IsEmpty) work according to the Function Reference guide?
                        LeoB
                          

                        Ninja:

                         

                        Thanks for taking the time to reply.

                         

                        I did use that script method, much as you recommended.

                         

                        The Functions Reference is still not clear (at least to me) that the settings they give as an example will only work as a calculation, not as a script.

                         

                        Thanks