Kent Searight Posted September 25, 2005 Posted September 25, 2005 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.
Fenton Posted September 25, 2005 Posted September 25, 2005 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 ) )
Kent Searight Posted September 25, 2005 Author Posted September 25, 2005 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?
Lee Smith Posted September 25, 2005 Posted September 25, 2005 Post a copy of what you are working with, and what you wont' to parse out. HTH Lee
SlimJim Posted September 25, 2005 Posted September 25, 2005 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.
Kent Searight Posted September 25, 2005 Author Posted September 25, 2005 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
Paul de Halle Posted September 25, 2005 Posted September 25, 2005 This is a slight variation on the calc, but it's working fine now. PathNameParseFixed.fp7.zip
Kent Searight Posted September 25, 2005 Author Posted September 25, 2005 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!!!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now