Position (text field; "\\", 1, 1)
will find the first backslash in text field. (I just checked to be sure it'd work.)
Post some details and we'll see where it's not working for you.
Set Variable [$i ; 1]
exit loop if [Position (text field; "\\", 1, $i) = 0]
Set Variable [$i ; $i + 1]
If [Position (text field; "\\", 1, $i-1) > 0 ]
Set Variable [$LowestFolder; Right ( text field ; Length (text field ) - Position (text field; "\\", 1, $i-1) )
This works if the lowest level folder in the path does not have a '\' to the right of it. IF it does, you'll need to adjust the script accordingly.
Trying to parse Get(FilePath) ... using "\\" as the search... but I always get 0 as answer.
That is the correct answer. The result of Get(FilePath) does not contain any backslash characters. To get the name of the current file's enclosing folder, try:
Let ( [ path = Get ( FilePath ) ; len = Length ( path ) ; s = Position ( path ; "/" ; len ; -2 ) ; e = Position ( path ; "/" ; len ; -1 ) ] ; Middle ( path ; s + 1 ; e - s - 1 ) )
Thanks for your usual good help. However in this case I discovered
that Filemaker Pro 9 advanced is converting the normal Windows "\" backslash
in Get(FilePath) return to forward slash "/" which I believe is Unix format.
I should have been looking for "/". Has Filemaker always converted this
way or is it more recent ? Always appreciate your help. CountryBoy1
Here's the code that gets me the lowest Folder name in a file path. It uses
another field, FolderName which is TrimAll( Get(FilePath) ; 1, 3) which takes all spaces
out of the long file path. Incidently my filepath was about 80 characters long. I am
using Windows XP Professional. (Hope that Vista works the same because my program
is going on a Vista machine.)
Middle (FolderName ; Position( FolderName ; "/" ; Length ( FolderName ) ; -2) +1 ;
Position( FolderName ; "/" ; Length ( FolderName ) ; -1) - Position( FolderName ;
"/" ; Length ( FolderName ) ; -2) -1)