Skip to main content

Serial_SetDispatchScript (function reference)

By July 1, 2023July 17th, 2023Online Help, Troi Serial Plug-in
Troi Serial Plug-in > Functions reference > Serial_SetDispatchScript
Troi Serial Plug-in for FileMaker Pro

Serial_SetDispatchScript

Sets the script to trigger when data is received. If you give an empty filename parameter “”, the dispatch script is removed.

SyntaxFunction badge

Serial_SetDispatchScript ( switches ; portname ; filename ; scriptname ;
                           matchstring )

Parameters

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

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.

Returned Result

Data type returned

Error code

Result

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.

Originated in

Troi Serial Plug-in 3.0

Compatibility

FileMaker Pro 16 to FileMaker Pro 2023

Considerations

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.

Example

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.

Example 2

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.

Used in example file

Terminal.fmp12

Related script stepScript step badge

Set Serial Trigger Script

Related topics

Troi Serial Plug-in online help (overview)


Online Help Page for Troi Serial Plug-in for 16 to 2023 –> Serial_SetDispatchScript (serip4810) 2023-0717 13:05:50