Custom Function for Paths in FMP Temp Directory

Document created by steve_ssh on Aug 10, 2018Last modified by steve_ssh on Aug 22, 2018
Version 5Show Document
  • View in full screen mode



This document is home for a custom function that I use whenever I need to work with an external file that is (to be) located in the FMP temp directory.


Because different functionality requires different styles of path (e.g. FMP path, Posix path, URL), I found it helpful to encapsulate the details of proper path composition into a single function.


The function takes care of determining the necessary path syntax, the location of the FMP temp directory, and any needed character escaping.  I have found that it helps to keep code clean, and removes any headache associated with how to properly construct the needed path as I code.



Common Use Cases Include:


   FMP-style path:


     Export Records script step

     Import Records script step

     • Export Field Contents script step

     • Save Records As ______ script steps


   Reference via URL:


     • Loading a temp directory file into a WebViewer

     • Referencing a temp directory file's data as Javascript, CSS, or other content within HTML/JavaScript code

     Insert From URL script step


   Posix Path:


     • Manipulation of a temp directory file with a plug-in (typically a shell/bash script)

     • Generating commands which are to be run from via Terminal



Over the years, the custom function has evolved to account for various needs and gotchas which I have stumbled over:


     • Allowance for relative sub-paths, i.e. more than just a single file name, to allow for work with files in their own directories/folders

     • URL encoding with attention to a detail where I found that FMP url-encoding differed from what was needed

     • Single-quoting of strings for shell-script ultimately worked better for me than backslash-escaped spaces

     • For bash scripts: proper escaping of single-quote characters within the file name/path

     • Deliberate inclusion of  /Volumes/DriveName for bash/URL to accommodate rare cases where FMP temp dir was not on the main volume

     • Attention to escaping chars, as needed, to handle cases where the MacOS main hard drive has been renamed





     • I have begun some work towards supporting the Windows platform (incorporated into the most recent attached archive), but it is not yet tested.

    • I believe that it might work in an iOS context, but I have not tested to confirm this is the case.

     • It turns out that the originally posted version of the CF did not work on iOS.  That has been addressed in the most recent update (2018-08-22).





     • Thanks for taking a look.

     • If there is a Windows path expert who is able to share their skills towards making this function be cross-platform compatible, please let me know.

     • Though I have not needed it, creating a companion function which targets a file in the Documents directory should be a straight-forward task.

     • Attached to this document should be a sample file which includes the latest version of the custom function.



Update 2018 Aug 22 10:40 pm Pacific: I have replaced the attached archive with an updated version which fixes a compatibility issue with iOS use, and which aims to set the groundwork for Windows use.  This has not yet been tested on Windows -- it is presently unknown whether it works in Windows.  What can be said is that some issues that previously prevented the CF from working in Windows have now been addressed, but not tested.  Work still remains to support plug-in paths on Windows.  Also -- it still remains for me to confirm that this CF works in FMS environments.  I recommend that anyone who has a copy of the original file here replace it with the updated archive ( ). Thank you.



5 people found this helpful