
The Initial Loading Script
To make the most of the ACF Plugin, you need to perform some initialization steps beyond simply placing it in the plugins folder. These steps are crucial for harnessing the plugin's full potential. Here's a breakdown of what you need to do:
Note: An example of this can be found in the "ACF-Devstarter" application, you can simply cut and paste from this instead of making it all, but here is the steps if you prefer to do:
Verification and Installation: First, you should verify whether the plugin is installed. If it's not already installed, you need to install it.
Loading Binaries: Next, load the binaries for your compiled sources.
Bootstrap Package Compilation: Check if you have the Bootstrap package installed. If it's not there, compile it from the source. The Bootstrap package is essential for your development environment.
Plugin License Registration: Lastly, you should register the plugin's license. Without this, the plugin will only work for 30 minutes. Therefore, it's recommended to do this step last. If you only deploy a runtime license (instead of a developer license) too early, it can hinder compilation in step 3.
The code to perform these initialization steps should be placed in your "Startup" FileMaker Script. If you don't already have a startup script, create one. Then, go to File Options and Triggers and select your startup script to run "On First Window Open."
Run this script from the script workspace, and your plugin will be all setup.
In this setup, we assume that you have the Preferences ACF fields from the ACF_Devstarter application defined. For details about this setup, please refer to the first video in the "Demo Videos" section of this manual.
Preparing a Source File for Step 3
If you have the compiled binary for it in one of the ACF_Pack1...ACF_Pack4 fields in your preference table, this step is not needed as it will load in step 2. However, if you start your application without any records in your preference table or the fields are empty, this is a fallback mechanism to ensure the bootstrap package is loaded.
Unfortunately, you can't include the source code directly within a calculation due to FileMaker's new-line behavior in calculations. To work around this, use the the following:
Create a script step:
Insert Text
. ChooseSelect
, and for target checkVariable
, and name it$$Source
for example. Below the variable, a text field comes up where you can paste in the source code found in "bootstrap.acf". In this way, the text is pasted as-is, and there is not removed any linebreaks from it.Then a second script step,
Set Variable
, and$res
, and the formula isACF_Compile($$Source)
If [ ACF_run("bootstrap_AreWeLoaded") ≠ "Yes" ]
Insert Text ( Select; $$Source; 'package bootstrap "Functions to facilitate..."')
Set Variable [ $res; Value:ACF_Compile( $$Source ) ]
End If
Here is some images:
Example of a startup script
# Initialize the ACF Plugin
# 1. Verify if we have the plugin, if not, install it.
Go to Layout [ “Preferences” (Preferences) ]
If [ dsPD_Version( "autoupdate" ) >= "01060200" ]
Perform Script [ “Install Plugin” ]
Pause/Resume Script [ Duration (seconds): ,3 ]
End If
# 2. Load the binaries for our compiled sources.
Set Variable [ $$ACF;
Value:Let( [
v = If (not IsEmpty ( Preferences::ACF_Pack1) ;
ACF_Install_base64Text( Preferences::ACF_Pack1 ); "") ;
v = v & If (not IsEmpty ( Preferences::ACF_Pack2) ;
ACF_Install_base64Text( Preferences::ACF_Pack2 ); "") ;
v = v & If (not IsEmpty ( Preferences::ACF_Pack3) ;
ACF_Install_base64Text( Preferences::ACF_Pack3 ); "") ;
v = v & If (not IsEmpty ( Preferences::ACF_Pack4) ;
ACF_Install_base64Text( Preferences::ACF_Pack4 ); "")
]; v ) ]
# 3. Checking if we have the bootstrap package, if not, compile it from the source.
# (As it is mandatory for our development environment)
If [ ACF_run("bootstrap_AreWeLoaded") ≠ "Yes" ]
Insert Text ( Select; $$Source; 'package bootstrap "Functions to facilitate..."')
Set Variable [ $res; Value:ACF_Compile( $$Source ) ]
End If
#3. Registering the plugin's license. Either from preferences, or from hard-coded license
Set Variable [ $reg;
Value:ACF_RegisterPlugin( Preferences::ACF_LicenseName; Preferences::ACF_LicenseKey ) ]
# Verify that the registration went OK, if not show an error.
If [$reg ≠ "OK"]
Show Custom Dialog ["ACF-Plugin"; "Error registering the plugins license: " & $reg]
End If
# Any other initialization needed for our application.
You can cut and paste those steps from the dev-starter.