Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script using file extension in a container field

Featured Replies

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.

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

  • Author

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

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.