If you get as text (containerfield) you should be able to extract the original filename and use the Left text function to get the .xxx to get the right extension.
No get function needed as far as I can tell from your post.
Try this calculation to extract the file extension:
Let ( [ R = GetasText ( ContainerField ) ; L = Length ( R ) ] ;
Right ( R ; L - Position ( R ; "." ; L ; -1 ) + 1)
) // let
SET VARIABLE $path
"file:" & Get ( DesktopPath ) & TALENT::TALENT First & " " & TALENT::TALENT Last & Let ( [ R = GetAsText ( TALENT::HEADSHOT RESUME ) ; L = Length ( R ) ] ; Right ( R ; L - Position ( R ; "." ; L ; -1 ) + 1) ) // let
Was wondering, for archives and educational purposes..explain the why this "Let" statement works?
I'm not sure how the --- L and R - 1 + 1 --- items work. I'm dumfounded when I look at it. I would like to understand better.
Let is a way to assign values to variables that can then be used either: inside the let function itself (what we did), in subsequent steps in the same script (If $ is used as the first character of the variable name) or throughout the data base file (If $$ is used as the start of the variable name).
I used it to set up two variables, R and L. If you removed this let function, you'd have to replace R with the name of your container field and L with the length of the text from this container field.
The position function can be looked up in FileMaker help. It's parameters are: text;searchString;start;occurrence
We made L, the starting point so that Position first "looks" at the last character in R--the file reference stored in the container field. A negative value in the occurrence parameter makes the search work from right to left instead of left to right, so -1 tells the function to return the postion of the first "." found, starting from the last character and searching from right to left.
If you had R = "FileName.JPG", L would be 12 and the position function returns 9. 12 - 9 returns 3, but we want the right 4 characters, not the right 3 so we add one.
I'm embarrased to admit that I now see a much simpler expression: Right ( Containerfield ; 4 ) should work equally well here in place of this complex confection that I originally posted.
Very interesting..funny how two answers can be done to get the same result.
In the shorter answer as replacement would be.
"file:" & Get ( DesktopPath ) & TALENT::TALENT First & " " & TALENT::TALENT Last & Let (Right (Containerfield ; 4 )
..and is basically is saying ...get the the last 4 digits from the right side of the container contents name and place it here in the filename.
Yes much simpler. Is this like algebra and simplifying the equation???
FYI..I didn't do well in algebra...but I get this easier than algebra.
AS I was finishing my previous post, it occurred to me that what you want will always be the last 4 characters of the text so there was no need to compute the position of the period that starts the file extension.
You don't need the let function in this last version. You can just use Right ( container field ; 4 )