Other Tips

From FM Plugin Wikipedia
Revision as of 23:23, 11 July 2007 by Admin (talk | contribs) (Do_StartScript)

Jump to: navigation, search

This page is about editing and working with the Calc Engine, Client and Types passed from FileMaker to your plugin.


Do_StartScript

The default FM 7 API includes the function 'Do_StartScript' works okay, but by default, it doesn't allow you to pass any text to the called script which can then be retrieved using 'Get(ScriptParameter)'


You can modify the script as below, which allows the user to pass an optional (in this example) third parameter, which is then passed to the called script.


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

	fmx::ulong nParams = dataVect.Size();
	
	if (nParams > 2)
	{
		// This function will trigger the execution of a script in FileMaker Pro, passing the text as parameter to the script.
		errorResult = FMX_StartScript( &(dataVect.AtAsText(0)), &(dataVect.AtAsText(1)), kFMXT_Pause, &(dataVect.At(2)) );
	}
	else if (nParams > 1)
	{
		// This function will trigger the execution of a script in FileMaker Pro with no paramater.
		errorResult = FMX_StartScript( &(dataVect.AtAsText(0)), &(dataVect.AtAsText(1)), kFMXT_Pause, NULL );
	}
	else
	{
		errorResult = -1;	// This is just an example of returning an error
 	}// nParams > 1
	
	return(errorResult);
} // Do_IDMA_StartScript

Make sure in your Function Setup, you have set Min to 2 parameters, and Max to 3 parameters.