ACF Library

acflib_Editor_button

Back to List

Description: Function to facilitate a button script to edit some content in an external editor.

FileMaker Prototype:

Set Variable [$res; ACF_Run("acflib_Editor_button")]

Category: UTILITY

Function source:

function acflib_Editor_button()
   string MDText = ACF_Functions::longDesc; 
   string tmpMDfile = ACF_Functions::tempMDfile;
   string fuName = ACF_Functions::FunctionName; 
   string mdContent; 
   int x; 
   if ( tmpMDfile == "") then
      if ( MDText == "") then
         MDText = "**" + fuName + "** \n\n\n**Example**\n```\n"+ACF_Functions::fmCalc+"\n```"; 
      end if
      
      tmpMDfile = temporary_directory()+"/" + fuName + ".md";
      x = open (tmpMDfile, "w" ); 
      write (x, MDText); 
      close (x); 
      $$mdFile = tmpMDfile; 
      return MDText; 
   
   else
      x = open ( tmpMDfile, "r"); 
      mdContent = read ( x); 
      close x; 
      $$mdFile = "";
      return mdContent; 
   end if
   return "OK"; 
end 

acflib_Editor_button Is used by the ACF lib service application to streamline the editing of the content of the library.

  • It uses a field to hold a temporary file path for a OS file.
  • If that field is empty, we are in the mode of starting the editor. If the previous content is empty, we create some default content containing the function name, and some example. Otherwise we write the content of the markdown field to the file.
  • The function sets some FileMaker variables, including the path of the stored file. The calling script uses Open URL script-step to open the file in the favourite editor.
  • If it is called with a previous path stored, it opens the file, read its content, and return back to the calling script.
  • The button in the layout, have a duplicate. One with "Hide object when" checks for empty path, and the other for a nonempty path. Both calling the same script. The text for the first button has "Editor", and the other has "load back".

This streamlines the editing of content for the documentation.

Example

Set Variable [$res; ACF_Run("acflib_Editor_button")]
=>Returns the edited content. 
Back to List