2 Replies Latest reply on Dec 19, 2013 4:51 AM by TechsupportLito

    What is wrong with my calculation?

    TechsupportLito

      Title

      What is wrong with my calculation?

      Post

           Quite new at using FileMaker so this may be a real beginners question but i have to get this working.

            

           I'm trying to calculate a file path from the files name and there are two kinds of files.

           One type of file is always named like this, 01-23456.jpg and the other one i always named abcd_123456.jpg. These images are located in two different folder structures and i need to calculate where they are.

           If i make two different calculations like this.

           If ( Left (img1;2)    ≥    0 ; settings::path_image_display & "MyFolder1/" & Left ( img1 ; 2 ) & "/" & img1  )

           and

           If ( Left (img1;5) =  "abcd_"; settings::path_image_display & "MyFolder2/" & Left ( img1 ; 9 ) & "/" & Substitute ( img1; "_M" ; "" ))

           they do both work just as i want them to. But since i don't know in advance what type of image field img1 will be i do need to make a combination of these two calculations and this is what i have come up with so far.

           If (img1 ≠ ""; 

            
           Case ( If (Left (img1;2)   ≥   0  ; settings::path_image_display & "MyFolder1/" & Left ( img1 ; 2 ) & "/" & img1) ;
            
           If (Left (img1;5) = "abcd_" ; settings::path_image_display & "MyFolder2/" & Left ( img1 ; 9 ) & "/" & Substitute ( img1; "_M" ; "" )) ))
            
           As you can see i have also added a rule that this will only be calculated if the field has an value. 
            
           The combined calculation works just fine if an abcd_123456.jpg image is entered in img1 but when i enter 01-23456.jpg the value returned is none and i just can't figure out why.
            
           My calculation is set to be returned as text.

           Any help is appreciated!!

           /Fredrik

        • 1. Re: What is wrong with my calculation?
          philmodjunk
               You don't need the outer If function as far as I can tell here.

               Case ( Left (img1;2)   ≥   0  ; settings::path_image_display & "MyFolder1/" & Left ( img1 ; 2 ) & "/" & img1 ;
                           Left (img1;5) = "abcd_" ; settings::path_image_display & "MyFolder2/" & Left ( img1 ; 9 ) & "/" & Substitute ( img1; "_M" ; "" )
                        )   

               Should do the trick. You might want to look up the case function in FileMaker help to learn more about how the syntax for this workhorse function is set up.    
          • 2. Re: What is wrong with my calculation?
            TechsupportLito

                 Thanks for an quick reply and a much more streamlined calculation.

                  

                 This is the final calculation that works just fine.

                 Case ( GetAsNumber(Left (img1;2))    >    0  ; settings::path_image_display & "MyFolder1/" & Left ( img1 ; 2 ) & "/" & img1 ;
                             Left (img1;4) = "ells" or Left (img1;4) = "high" or Left (img1;4) = "eldm" or Left (img1;4) = "joss"; settings::path_image_display & "MyFolder2/" & Left ( img1 ; 9 ) & "/" & Left ( img1 ; 12 ) & ".jpg"
                          )
                  
                 It turned out that some images was wrongly labeled _M1 so i had to use an harder way to remove everything from character 12 in the filename and it was necessary to add GetAsNumber to be able to get all these images without having to specify 01, 02, 03 … 99.
                  
                 /Fredrik