![]() |
Serial_SetDirectInsert |
Specifies how to insert data directly into the database when data is received. If you give an empty filename parameter, the direct insert is canceled.
Syntax
Serial_SetDirectInsert ( switches ; portname ; filename ; tablename ;
fieldname ; matchstring )
Parameters
switches | modifies how this function behaves |
portname | the name of the serial port to be coupled to this direct insert setting |
filename | the name of the file where the data needs to be inserted into |
tablename | the name of the table occurrence where the data needs to be inserted into |
fieldname | the name of the field where the data needs to be inserted into |
matchstring | (optional) wait for a match string before inserting the data |
Switches
switches can be one of this:
-GetLastMatch | the last string of text that matches the match string will be inserted |
-ConvertBytesToNumbers | converts all received bytes to their numeric value, with space as separator |
You can also add this switch:
-DontShowExtendedPrivilegeWarning | show no alert if direct insertion fails |
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 | DirectInsert was set |
$$-50 | paramErr | there was an error with the parameters |
Other errors may be returned.
Originated in
Troi Serial Plug-in 5.5
Compatibility
FileMaker Pro 18 to FileMaker Pro 2025
Considerations
If the filename parameter is empty, the plug-in will no longer insert data directly into the database.
The switch -ConvertBytesToNumbers was added in version 7.0.
NOTE You might need to enable “Validate cross-file plug-in access” extended privilege (fmplugin extended privilege) in newly created fmp12 files, for direct insertion to work.
See our web page for more info on how to do this here.
New in v9.0: the plug-in now shows an alert dialog when direct insertion fails because of insufficient privilege.
You can also add the switch “-DontShowExtendedPrivilegeWarning”, if you don’t want an alert to be shown if direct insertion fails.
Example
Set Variable [ $ErrorCode ; Serial_SetDirectInsert ( "-Unused" ; "port1" ;
Get ( FileName ) ; "IncomingData" ; "dataField" ; "OK" ) ]
This will set the Direct Insert for port1. Incoming data will be inserted into field “dataField” of table “IncomingData” of the current file. The data will not be inserted before the string “OK” is found.
Set Variable [ $ErrorCode ; Serial_SetDirectInsert ( "-Unused" ; "COM2" ; Get ( FileName ) ;
"IncomingData" ; "dataField" ; "¶" ]
This will set the DirectInsert for the COM2 port. Data will be directly inserted into field “dataField” of table “IncomingData” of the current file when a return is found in the incoming data.
Example 2
Set Field [ gErrorCode ; Serial_SetDirectInsert ( "-Unused" ; "COM2" ; "" ) ]
This will reset the DirectInsert. Although the incoming data is still buffered, no action is taken when data is received. You can still get the incoming data by calling the Serial_Receive( ) function.
Used in example file
Measure Temperature.fmp12
Related function
Serial_Open |
Related script steps
Set Serial Direct Insert |
Set Serial Trigger Script |
Related topics
Troi Serial Plug-in online help (overview)