September 25, 200520 yr I've been trying to get a file name from the end of a path name (on Windows) with the following formula: Right (pathFile ; Position (pathFile ; "" ; Length (pathFile ) ; -1 ) ) The problem is that the backslash ()used in Windows file paths is rejected by the calculation dialog when I try to save the calculation. How can I get around this? Any help is appreciated.
September 25, 200520 yr Since a backslash is actually an escape character itself (it is escaping the " in your calculation), then you need to put 2 when you want a backslash in your calculation. Right (pathFile ; Position (pathFile ; "" ; Length (pathFile ) ; -1 ) )
September 25, 200520 yr Author Thanks, Fenton. Now the calc dialog accepts it but...the calculation doesn't work. The Length() seems to return the inverse of what I want. Any ideas why?
September 25, 200520 yr Post a copy of what you are working with, and what you wont' to parse out. HTH Lee
September 25, 200520 yr I have used the following two calculations, WinURL is the fully specified file and path name returned by FMP from a getAsText(file) where file is a container containing a file reference. filepath = Left(WinURL;Position(WinURL;"";0;PatternCount ( WinURL ;"" ))) filename = Right(WinURL; Length(WinURL) - Length(File Path)) I can't see why this should work and yours not.
September 25, 200520 yr Author Hi Lee, Here's a sample file of what I'm trying to do. Something is obviously wrong with my calc but I can't figure it out. Hopefully you can show me where I've erred. Hi Slim Jim, I'm going to give your calculations a try also, but first I want to find out where the error lies in the way I'm attempting to parse the name out. Thanks to all!!! : PathNameParse.zip
September 25, 200520 yr This is a slight variation on the calc, but it's working fine now. PathNameParseFixed.fp7.zip
September 25, 200520 yr Author Nicely done, Paul. I realize now where my logic wasn't correct. And setting the "occurrence" parameter in Position() by using the PatternCount value of "" is (in my humble opinion) a superior approach to my attempt to search backward in the Position() function. Many thanks!!!
Create an account or sign in to comment