FMWrapper Framework

From FM Plugin Wikipedia
Revision as of 23:31, 7 July 2007 by Admin (talk | contribs) (Number Parameters Passed)

Jump to: navigation, search

These pages are about the FM Wrapper Framework which is supplied by FileMaker and must be included in order to compile plugins for FileMaker


It should be noted, that the FMWrapper.framework itself cannot be published on the internet for others to download or view as you will be in breach of the FMI license agreement.



Number Parameters Passed

The new API allows you to accept multiple parameters which are passed in the Function Call. eg. IDMA_FunctionName( param1 ; param2 ; param3 ; etc )


When registering your function, parameters 5 & 6 refer to the min & max (respectively) number of parameters the user can/must supply. If they are the same, then the user must specify that many parameters. If different, then the user can specify any number between the min & max values.


  • err = fmx::ExprEnv::RegisterExternalFunction(*pluginID, kIDMA_ConvertScript, *name, *prototype, 3, 4, regFunctionFlags, Do_Convert );


Now, in your function, when you want to find out the number of parameters the user actually passed, you can include the following line.

  • fmx::ulong nParams = dataVect.Size();

where

  • fmx::ulong - filemaker type 'unsigned long' (See FMXExtern.h)
  • nParams - variable to store the result, in this case the number of parameters passed by the user
  • dataVect.Size() - returns a ulong number (see FMXCalcEngine.h)


Out of habbit, I suggest checking the number of Parameters passed, even if you have specified a min / max to be the same.

as in the following example.


FMX_PROC(fmx::errcode) Do_XMpl_Append(short /* funcId */, const fmx::ExprEnv& /* environment */, const fmx::DataVect& dataVect, fmx::Data& results) { fmx::errcode errorResult = 0;

// if (funcId != kXMpl_Append) // Then somehow this function was called incorrectly. This is not likely // to happen unless the plugin registers a different number of functions depending on some condition.

// Append an arbitrary number of strings together. fmx::TextAutoPtr resultTxt; fmx::ulong nParams = dataVect.Size(); fmx::ulong j;

if (nParams > 0) { for ( j = 0; j < nParams; j++ ) { resultTxt->AppendText( dataVect.AtAsText(j), 0, static_cast<fmx::ulong>(-1) ); }

results.SetAsText( *resultTxt, dataVect.At(0).GetLocale() ); } else { errorResult = -1; // This is just an example of returning an error.

}// nParams > 0


return(errorResult); } // Do_XMpl_Append