Command: FunctionID

The FunctionID command allows you to register a function as a plugin function, making it accessible using just ACFU_function_name instead of ACF_run("function_name"). This is particularly useful for frequently used functions as it provides the prototype as an autocomplete option when used in FileMaker. Functions used internally as helper functions within another ACF function do not require FunctionID; it's mainly for functions intended to be used directly in FileMaker calculations.

When functions are used within another ACF function, no prefixing is necessary. The prefixing only applies when calling functions from FileMaker calculations.

Parameters:

Parameter name Type Description
ID Number constant A unique constant between 200 and 32767 that identifies the function.

It's essential to manage these function IDs systematically, maintaining a record of them in a database or spreadsheet. Avoid sharing the same function ID among different functions. Changing the function ID can break script steps that use it, so stick with the function ID once it's assigned.

When you receive ACF sources from another developer, check that their function IDs don't conflict with yours. Renumber functions from external sources if needed to prevent overlap. Avoid accepting binary packages from other developers, as it can make maintenance challenging. Future plugin releases might require you to recompile sources. Binary packages are suitable for deployment in end-user applications.

We automatically prefix all function names with ACFU_ when they are used in FileMaker script steps. This serves several purposes:

Screenshots:

ACFU Autocomplete

ACFU Prototype

Return value:

No return value

Example:

function abc ( int a, int b ) 
    functionID 10232; 
    
    return format ( "The value of a is %d, and b is %d", a, b); 
end 

Then later, the function can be called using:

Set Variable ($x; ACFU_abc (2, 3) )

Pros and Cons:

There are pros and cons to registering functions with a "FunctionID." The most obvious benefit is easy access to functions in the FileMaker development environment, along with convenient access to function prototypes to fill in parameters. However, you need to ensure that your code is loaded in the startup script so that it's available during development.

The cons include the need to have functions loaded continuously while developing. If you edit a script without loading your ACF code and save it, the script will display "," and once saved, it becomes inoperative. When using ACF_run, such issues result in a runtime error only when running the script.

The ACF_GetAllPrototypes function provides a handy list of loaded prototypes, allowing you to copy and paste them into an accessible document for reference.

References:


This section explains how to use the FunctionID command to register functions as plugin functions, the benefits of doing so, and considerations when working with function IDs. It also provides examples and discusses the pros and cons of this approach.