Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4384 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I saw some posts regarding extracting file name and path from a container

 

 

What I need is a little different:

 

 

I have a container field (FM Pro 11 Advanced) with a link to external files.

 

 

I need to find a way to extract the file extension. The path and the name itself are totally useless for what I want to do.

 

 

Then I need to capture that info inside a script that would go like this:

 

Case  extension is .jpg      extract content    then open the file

Case  extension is .doc     extract content    then open the file

Case  extension is .pdf      extract content    then open the file

etc

End case

 

 

What I'm trying to do, is to be able to open the file by double clicking on the container field whatever the type of the file inside. Using ''extract content'' I can do it say for any PDF file, but  that container will also be used for many other types of file.

 

The easy way to have all this, would be to upgrade to FM 12,  but it is a costly upgrade for what little I need.

 

I fumbled a lot with the getastext function combined with substring functions without even coming close to a result.

 

Can someone help me with this? I have little experience with scripts and formulas.

Posted (edited)

Try =

 

Let ( [
path = GetAsText ( Containerfield ) ;
len = Length ( path ) ;
pos = Position ( path ; "." ; len ;  -1 )
] ;
Right ( path ; len - pos )
)

 

 

Of course, if the extension is always 3 characters long, you could do just =

Right ( Containerfield ; 3 )

 


 

Edited by comment
  • Like 1
Posted

Thank you for your help.  This is exactly what I needed.

 

Now I can open any type of file just by clicking the container field.

 

SD

This topic is 4384 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.