Jump to content

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

Recommended Posts

Posted

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.

Posted

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 ) )

Posted

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?

Posted

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.

Posted

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

Posted

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!!!

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