Brian Dunning's FileMaker Custom Functions

PathMaker ( thePath ; theFile ; pathSeparator )

Returns a properly formatted folder and/or file path by processing and combining thePath, theFile, and pathSeparator.

  Average rating: 4.8 (12 votes) Log in to vote

Lewis Lorenz   Lewis Lorenz - Show more from this author
Lorenz Companies
http://www.LorenzCom.com

Share on Facebook Share on Twitter

  Sample input:
PathMaker ( "Macintosh HD2:Users/user/Documents:" ; "" ; "" )
PathMaker ( Get ( DocumentsPath ) ; "" ; ":" )
PathMaker ( Get ( DocumentsPath ) & "My Folder" ; "Untitled:/1.txt" ; "" )
PathMaker ( "file:" & Get ( DocumentsPath ) ; "Invoice.pdf" ; "" )
PathMaker ( Get ( DocumentsPath ) & "My Folder:Brochures:" ; "Untitled1.pdf" ; "" )
PathMaker ( Get ( DocumentsPath ) & "My Folder:Brochures:" ; "Untitled1.pdf" ; "\\" )
  Sample output:
:Macintosh HD2:Users:user:Documents:
:Macintosh HD2:Users:user:Documents:
/Macintosh HD2/Users/user/Documents/My Folder/Untitled__1.txt
file:/Macintosh HD2/Users/user/Documents/Invoice.pdf
/Macintosh HD2/Users/user/Documents/My Folder/Brochures/Untitled1.pdf
\Macintosh HD2\Users\user\Documents\My Folder\Brochures\Untitled1.pdf

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

PathMaker ( thePath , theFile , pathSeparator )

Returns a properly formatted folder and/or file path by processing and combining thePath, theFile and pathSeparator.

Easily change path separator in thePath.
Preserves FileMaker Pro file reference prefixes (file:, filemac:, and filewin:).
Conforms different separators in thePath to one only.
Replaces errant separators in theFile with underscores.
Separator defaults to the first path separator in thePath or to the system path separator if pathSeparator is blank.
Concatenates thePath and theFile into a properly formatted file path.
Use with the PathParser custom function for added path formatting control.

Parameters

thePath - A folder path.
theFile - A file name to append to thePath.
pathSeparator - The separator used to separate folders in the thePath: /:\. If left blank the first found separator in thePath is used.

Examples

PathMaker ( "Macintosh HD2:Users/user/Documents:" ; "" ; "" ) = :Macintosh HD2:Users:user:Documents:
PathMaker ( Get ( DocumentsPath ) ; "" ; ":" ) = :Macintosh HD2:Users:user:Documents:
PathMaker ( Get ( DocumentsPath ) & "My Folder" ; "Untitled:/1.txt" ; "" ) = /Macintosh HD2/Users/user/Documents/My Folder/Untitled__1.txt
PathMaker ( "file:" & Get ( DocumentsPath ) ; "Invoice.pdf" ; "" ) = file:/Macintosh HD2/Users/user/Documents/Invoice.pdf
PathMaker ( Get ( DocumentsPath ) & "My Folder:Brochures:" ; "Untitled1.pdf" ; "" ) = /Macintosh HD2/Users/user/Documents/My Folder/Brochures/Untitled1.pdf
PathMaker ( Get ( DocumentsPath ) & "My Folder:Brochures:" ; "Untitled1.pdf" ; "\\" ) = \Macintosh HD2\Users\user\Documents\My Folder\Brochures\Untitled1.pdf

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: