Sets the script to trigger when data is received. If you give an empty filename parameter “”, the dispatch script is removed.
Serial_SetDispatchScript ( switches ; portname ; filename ; scriptname ; matchstring )
|switches||modifies how this function behaves|
|portname||(optional) the name of the serial port to be coupled to this trigger script. If you leave this empty the trigger script applies to all ports|
|filename||the name of the file with the Dispatch Script|
|scriptname||the name of the script to be triggered|
|matchstring||(optional) a string that must be matched before the script is triggered|
switches can be one of this:
|-ResumeWhenScriptPaused||when a trigger script needs to run, and an other script is already paused, the paused script will resume after the triggerscript is finished.|
Data type returned
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
|0||no error||the Dispatch Script was set|
|$$-50||paramErr||there was an error with the parameter|
Other errors may be returned.
Troi Serial Plug-in 3.0
FileMaker Pro 14 to 18
See also the User Manual under Dispatch Scripting for more details.
If the filename parameter is empty, the dispatch script is removed and the plug-in will no longer trigger a script. Note that this will only remove the general port trigger.
Set Field [ gErrorCode ; Serial_SetDispatchScript ( "-Unused" ; "" ; Get ( FileName ) ; "Read Script" ; "OK" ) ]
This will set the Dispatch Script for all ports to the script “Read Script” of the current file. The script will not be triggered before the match string “OK” is found.
Set Field [ gErrorCode ; Serial_SetDispatchScript ( "-Unused" ; "COM2" ; Get ( FileName ) ; "TriggerScriptCOM2" ; ]
This will set the Dispatch Script for the COM2 port to the script “TriggerScriptCOM2” of the current file.
Set Field [ gErrorCode ; Serial_SetDispatchScript ( "-Unused" ; "" ; "" ) ]
This will reset all the dispatch scripts. Although the incoming data is buffered, no action is taken when data is received. You can still get the data out by calling the Serial_Receive ( ) function.
Related script step
|Set Serial Trigger Script|