12 Replies Latest reply on Feb 22, 2015 5:24 PM by Mike_Mitchell

    How would I flag data in a container

    ramirezp6856

      Hello,

       

      Please consider the following container:

      Container.tiff

       

      The tabs consist of "Description, Internal Notes, Digital Docs, Inventory Log."

       

      I would like to create a script so that when one of these tabs have data the tab itself with be flagged with a radio button.

       

      Any suggestions will be greatly appreciated.

       

      Thanks,

       

      Phil

        • 1. Re: How would I flag data in a container
          Mike_Mitchell

          Hello, Phil. I'm assuming you have a series of container fields on the tab. If this is the case, you can use a calculation to add a radio button to the tab label by testing to see if any of the containers is empty. You don't need a script per se.

           

          Just use the "Specify" button on the tab control screen to specify the calculation. It might look something like this:

           

          "Digital Docs" & Case ( not IsEmpty ( containerField1 ) ; " " & Char ( 8226 ) ; not IsEmpty ( containerField2 ) ; " " & Char ( 8226 ) ; not IsEmpty ( containerField3 ) ; " " & Char ( 8226 ))

           

          Char ( 8226 ) will produce a radio button symbol. If you're on the Mac, you can produce it with Opt-8. Don't know what the equivalent is on Windows, but Char ( 8226 ) will work either way. You can add as many legs to the Case statement as you need. (There are more sophisticated ways to do the concatenation, but this will work.)

           

          HTH

           

          Mike

          • 2. Re: How would I flag data in a container
            ramirezp6856

            Thanks Mike for the prompt reply,

             

            I really like this method. Any ideas as to how I could set up a counter so I could keep track of the amount of pictures?

             

            Thanks again,

             

            Phil

            • 3. Re: How would I flag data in a container
              Mike_Mitchell

              Sure. One way would be to use a series of calculations like this:

               

              not IsEmpty ( containerField1 ) + not IsEmpty ( containerField2 ) + not IsEmpty ( containerField3 )

               

              This will give you a number equal to the number of container fields that are not empty. There are more sophisticated methods - the main weakness this one has it its dependence on hard-coding the fields into the calculation. But if you get to that point, you'll probably want to upgrade how the system is structured to make it more flexible anyway.

               

              HTH

               

              Mike

              • 4. Re: How would I flag data in a container
                erolst

                ramirezp6856 wrote:

                how I could set up a counter

                Mike_Mitchell wrote:

                not IsEmpty ( containerField1 ) + not IsEmpty ( containerField2 ) + not IsEmpty ( containerField3 ) […] There are more sophisticated methods

                 

                The obvious way is to use the function that does exactly that:

                 

                Count ( containerField1 ; containerField2 ; containerField3 )

                • 5. Re: How would I flag data in a container
                  Mike_Mitchell

                  Ugh. I never use Count ( ) this way, so didn't think of it. Thanks, Oliver.

                  • 6. Re: How would I flag data in a container
                    Mike_Mitchell

                    And Phil, since Oliver reminded me of this, the original calculation would be better as:

                     

                    "Digital Docs" & Case ( not IsEmpty ( Count ( containerField1 ; containerField2 ; containerField3 )) ; " " & Char ( 8226 ))

                     

                    Much simpler and easier to maintain.

                    • 7. Re: How would I flag data in a container
                      erolst

                      Mike –

                       

                      I hate having to correct you , but

                       

                      "Digital Docs"

                      &

                      Case (

                        Count ( containerField1 ; containerField2 ; containerField3 ) ;

                        " " & Char ( 8226 )

                      )

                       

                      is even simpler and more to the (Boolean) point …

                      • 8. Re: How would I flag data in a container
                        Mike_Mitchell

                        Yes, but we’re trying to use explicit coding. So mine isn’t “wrong” and in need of correction; it’s simply a different style. (IOW, now you’re splitting hairs.)  

                         

                        You could argue that

                         

                             Count > 0

                         

                        is better than

                         

                             not IsEmpty ( Count )

                         

                        and I might agree. But the implicit Boolean has been argued against on several occasions on this board (and other places) in favor of explicit coding.

                         

                        (And since we’re dealing with someone who’s relatively new to FileMaker here, this discussion is probably not helping him much at this point.)   

                        • 9. Re: How would I flag data in a container
                          erolst

                          Mike_Mitchell wrote:

                          Yes, but we’re trying to use explicit coding. So mine isn’t “wrong” and in need of correction

                          You're right, it wasn't in need of correction – wrong choice of word.

                           

                          But I didn't see any sign that says “explicit coding only” – regardless whether

                          the implicit Boolean has been argued against on several occasions on this board (and other places) in favor of explicit coding

                           

                          And though I would agree with the use of Count ( something ) > 0, I think that


                          not IsEmpty ( Count ( something ) )


                          unnecessarily muddies the waters …

                          Mike_Mitchell wrote:

                          And since we’re dealing with someone who’s relatively new to FileMaker here, this discussion is probably not helping him much at this point.

                          Why can't we have us a nice little chat on the side? The OP can read it or ignore it.

                          • 10. Re: How would I flag data in a container
                            Mike_Mitchell

                            Maybe because it unnecessarily muddies the waters?  

                             

                            There are certain things I think it's important for newbies to understand to avoid problems later. (Ex: Don't use repeating fields as a substitute for a related table.) But issues of coding style are probably left until later.

                             

                            But since you asked, personally, I tend to agree with the "explicit coding" side of that debate, especially when dealing with newbies. The implicit Boolean conceals things too much for most newbies. At least in my experience.

                            • 11. Re: How would I flag data in a container
                              user19752

                              You both seems forgetting that Count(field;field) never be Empty although both fields are empty, it returns 0.

                              • 12. Re: How would I flag data in a container
                                Mike_Mitchell

                                Yes, I realized that later. Count > 0 should be used for explicit coding, just plain Count for implicit. Thanks for contributing.