Jump to content

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

Recommended Posts

Posted

I see that someone else has posted a similar question recently with what seems to be a discouraging answer. Surely it must be possible to do this??

I’m trying to work out how to automatically enter an image’s file name into a text field when the image is imported as a link into a container field, “Image”. FMP can do this when using its import function, but that rigmarole isn’t well-suited to adding individual images sporadically.

I’ve tried setting up a calulation field using GetAsText(Image) which returns the following structure:

size:640,424

image:folder/folder/MD_006162.jpg

imagewin:/D:/folder/folder/folder/MD_006162.jpg

I then tried using RightWords to retrieve the last two words, but this is unreliable. FMP treats certain characters within the filename as separate words (spaces, underscores, dots, etc).

It seems as though I need to find a way to retrieve everything after the last forward-slash.

Can this be done by searching on the last slash somehow or is it really impossible?

Posted

Try this:

Middle ( master ; 1+Position ( master ; "/" ; 1 ; PatternCount ( master ; "/" ) ) ; 99 )

Where master is the stuff you get from GetAsText( ...I would probably do it with a Let( statement!

--sd

Posted

Søren you're a genius! Thank you so much.

I can tell that your formula is going to work because instead of "master" in you example, I substituted an intermediary calculation field name with the image text in it. Being a novice, I'm having trouble with the syntax to streamline these two steps into one. I've tried the below and a few variants, but can't get the first line to work. Any hints?

Let (GetAsText(Image) = master)

Middle ( master ; 1+Position ( master ; "/" ; 1 ; PatternCount ( master ; "/" ) ) ; 99 )

Posted

Go to help and study the syntax a Let( statement should follow.

You've reversed the order in the Let( and forgotten a ; or a , which it might be with your OS setup:

It should go like this:

Let (master = GetAsText ( Image ) ;

Middle ( master ; 1+Position ( master ; "/" ; 1 ; PatternCount ( master ; "/" ) ) ; 99 ))

--sd

Posted

Wow. It works perfectly now Søren, like a dream and just as I imagined it should. I'd never have worked out that PatternCount 99 solution myself though. I can't believe I had the order in that syntax reversed...

Thanks for reminding me to check the help section for this kind of thing too, which is surprisingly good - better than my reference book.

You've saved my wife heaps of unnecessary data entry, so thanks heaps.

This topic is 7142 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.