August 11, 200520 yr 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?
August 11, 200520 yr 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
August 11, 200520 yr Author 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 )
August 11, 200520 yr 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
August 12, 200520 yr Author 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.
Create an account or sign in to comment