GetFMDeclFromACF
Back to ListDescription: Parse an ACF function to retrieve the Prototype for calling it.
FileMaker Prototype:
Set Variable [$res; ACF_Run("GetFMDeclFromACF"; string_code)]
Category: UTILITY
Function source:
function GetFMDeclFromACF ( string code )
string func = between ( code, "unction ", char(41))+char(41);
print "Func: " + func + "\n";
string ptype, pname, call = "";
string fuName = trimboth (between ( "cc "+func, "cc ", char(40)));
print "FuName: " + fuName + "\n";
$$fuName = fuName;
string params = between ( func, char(40), char(41));
array string aParams = explode ( ",", params);
array string aParSplit;
array string aPlist;
string oneDecl, fuID = trimboth ( between (upper ( code), "FUNCTIONID ", char(59)));
int i, noPar = sizeof (aParams);
if ( fuID != "") then
call = "ACFU_" + fuName + ((noPar==0)?"":"(");
else
call = 'ACF_Run("'+fuName +'"'+ ((noPar==0)?")":";");
end if
clear(aPlist);
for (i=1, noPar)
oneDecl = trimboth(substitute (aParams[i], "array ", "array"));
aParSplit = explode (" ", oneDecl);
if ( sizeof ( aParSplit ) == 2) then
pType = aParSplit[1];
pName = aParSplit[2];
aPlist[] = " " + pType+"_"+pName;
end if
end for
if ( noPar == 0) then
call+= (( fuID != "")?"":")") ;
else
call+= implode ("; ", aPlist) + ")";
end if
call = "Set Variable [$res; "+call+"]";
return call;
end
GetFMDeclFromACF is a function used in the ACF library documentation project. It parses a functions source code, and come up with a prototype for calling it from FileMaker. This is then stored in a field in the ACF_Functions table, and later sendt to the wordpress site using a REST API.
The function looks at the declaration header, pull the function name, its parameters, and if there is defind a FunctionID. As all functions can be called using ACF_Run, having a unique function ID, makes it easier to call it from FileMaker, as autocomplete gives you the prototype right away. All the functions that has an FunctionID, is available in the calculation editor with a prefix ACFU_ and the function name. This prevent us from conflicts with filemakers own functions. Like having a ACF function called "Get", we should not mix that with filemakers "Get" function, therefore we call it ACFU_Get instead.
