5 Replies Latest reply on Sep 19, 2013 9:40 AM by philmodjunk

    If you want to have a check box that can filter container fields based on the type of file in side...

    ChrisJohnston

      Post

           If you want to have a check box that can filter container fields based on the type of file in side them, say for example
           Choice1 = psd, jpg, png, bmp, tga
           Choice2 = txt, doc, docx, xls, html, xml
           Choice3 = mov, mp4, avi, wmv
           Can you define Choice1, 2 and 3 each in a Case statement to put in a value list?
           Are there any functions that are helpful in deducing what type of file is in your container file?

        • 1. Re: If you want to have a check box that can filter container fields based on the type of file in side...
          philmodjunk

               Please explain how you want that "filter" to work. Do you have a set of records with a container field in each record where only the records with a file of the desired extension should be displayed? Or are you trying to limit the user to a specific type of file to be inserted into the container field?

               You can certainly put together the value list and you do not need a case function to do so.

               You can also extract the file name from any container field that holds a file--no matter what insertion or storage methods have been specified. And that file name will include the file extension. Thus, you could set up a calculation field set to return text that displays either the file extension or a "category name" for all files of a given group such as "Image, Text or Movie..." to match to your example here.

               See this thread (go to the last post) for a calculation that extracts the file name that handles all variations save one deprecated option not supported in FileMaker 12: Scripted Find Examples

               You may also find the exploration file that you can download from this thread helpful: Exploring the use of a $Path Variable in Scripts

          • 2. Re: If you want to have a check box that can filter container fields based on the type of file in side...
            ChrisJohnston

                 I am trying to limit the user to a specific type of file. Need a way to group all Image file, Text file, Media files in to one check box selection. Not to be inserted just to be visible as a choice they are already in a container.

            • 3. Re: If you want to have a check box that can filter container fields based on the type of file in side...
              philmodjunk

                   Limit records listed in a portal or records listed in the layout's found set? Same basic concept but the implementation details are quite different.

                   Either way, the calculation field that referred to can be set up to show the File Category in order to give you a way to limit either the found set or the related records to a specified general type.

                   Let ( [ T = If ( LeftWords ( YourTable::ContainerFIeld ; 1 ) = "remote" ; GetValue( YourTable::ContainerFIeld ; 1 ) ; GetValue ( YourTable::ContainerFIeld ; ValueCount ( YourTable::ContainerFIeld ) ) ) ;
                             L = Length ( T )];
                             If ( LeftWords ( T ; 1 ) = "remote" ;  Right ( T ; L - 7 ) ; Right ( T ; L - Position ( T ; "/" ; L ; -1 ) ) )
                       )

                   Returns the file name. That could be defined as a custom function, but let's just put it in a calculation field named "cFileName". Then this expression could return the desired category name for the type of file:

                   Let ( [ F = cFileName ;
                              L = Length ( F ) ;
                             P = Position ( F ; "." ; L ; -1 ) ;
                             Ext = Right ( F ; L - P )
                           ] ;
                           Case ( PatternCount ( "psd, jpg, png, bmp, tga" ; Ext ) ; "Image" ;
                                      PatternCount ( "txt, doc, docx, xls, html, xml" ; Ext ) ; "Text" ;
                                      PatternCount ("mov, mp4, avi, wmv" ; Ext ) ; "Audio-Visual" ;
                                      "Unknown" // Else result if extension is "none of the above".
                                     ) // Case
                           ) // Let

              • 4. Re: If you want to have a check box that can filter container fields based on the type of file in side...
                ChrisJohnston
                                                                                 
                                                          

                                         The code you gave, I was able to get something out of it. However I think that it is a little be over my head for now I am going to use it as something that can teach me, I had never see PaternCount() used in such a useful way and you showed it.

                                    

                                          

                                    

                                         The way I solved this and it works well was to put all my file format extensions in a Case statement
                                         Case (
                                         type = "psd" ; "Image" ;
                                         type = "jpg" ; "Image" ;
                                         type = "png" ; "Image" ;
                                         type = "txt" ; "Text" ;
                                         type = "xml" ; "Code" ;
                                         type = "html" ; "Code" ;...

                                         and I used this custom function as custom function I found at

                                         http://www.briandunning.com/cf/351
                                         RightSeparator ( text ; separator ; occurrence ; direction )

                                         used the

                                         Middle ( get_path ; Position ( get_path ; "/" ; Length ( get_path ) ; - 1 ) + 1 ; 999 )
                                         to get the extension

                                    

                                         That you showed me!

                                         Then used a method of letting a global work with the Value List and matched it in my Table Occurance. It works great

                                    

                                         http://pctechtv.com/fm/fiiter_list.html

                               

                      

                • 5. Re: If you want to have a check box that can filter container fields based on the type of file in side...
                  philmodjunk

                       Be careful. What I see may not work if you specify external storage for your file. In that case, the file name is not the last bit of text in the container field. That's something my calculation for the file name detects and corrects for.