Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Phidget.SetScriptTrigger

Installs a script trigger with the phidget.

Component Version macOS Windows Linux Server iOS SDK
Phidget 13.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ❌ No
MBS( "Phidget.SetScriptTrigger"; PhidgetRef; Event; FileName; ScriptName; Tag )   More

Parameters

Parameter Description Example
PhidgetRef The reference number for the phidget. $phidget
Event The name of the event. "Attach"
FileName The file name of the FileMaker database containing the script. Get(FileName)
ScriptName The script name of the script to trigger.
Tag Optional tag value.
Goes into the JSON passed to the script, so you can pass whatever you like to the script.

Result

Returns OK or error.

Description

Installs a script trigger with the phidget.
Please check phidgets documentation about what events are available for which device.
The JSON passed to the script will contains an entry for ID with the passed phidget reference number.

Available events:
Device ClassEventParameters
All devicesAttach-
Detach-
PropertyChangeproperty
ErrorerrorString, errorCode
AccelerometerAccelerationChangetimestamp, acceleration
BLDCMotorBrakingStrengthChangebrakingStrength
PositionChangeposition
VelocityUpdatevelocity
CapacitiveTouchTouchtouchValue
TouchEnd
CurrentInputCurrentChangecurrent
DCMotorBackEMFChangebackEMF
BrakingStrengthChangebrakingStrength
VelocityUpdatevelocity
Dictionary--
DigitalInputStateChangestate
DigitalOutput--
DistanceSensorDistanceChangedistance
SonarReflectionsUpdatecount, distances, amplitudes
EncoderPositionChangepositionChange, timeChange, indexTriggered
FrequencyCounterCountChangecounts, timeChange
FrequencyChangefrequency
GPSHeadingChangeheading, velocity
PositionChangelatitude, longitude, altitude
PositionFixStateChangepositionFixState
GyroscopeAngularRateUpdatetimestamp, angularRate
Hub--
HumiditySensor.HumidityChangehumidity
IRCodecode, bitcount, isRepeat
Learncode, codeInfo
RawDatadata, dataLen
LCD--
LightSensorIlluminanceChangeilluminance
MagnetometerMagneticFieldChangetimestamp, magneticField
MotorPositionControllerPositionChangeposition
DutyCycleUpdatedutyCycle
PHSensorPHChangeph
PowerGuard--
PressureSensorPressureChangepressure
RCServoPositionChangeposition
TargetPositionReachedposition
VelocityChangevelocity
ResistanceInputResistanceChangeresistance
RFIDTagtag, protocool
TagLosttag, protocool
SoundSensorSPLChangedB, dBA, dBC, octaves
SpatialAlgorithmDatatimestamp, quaternion
SpatialDatatimestamp, acceleration, angularRate, magneticField
StepperPositionChangeposition
Stopped-
VelocityChangevelocity
TemperatureSensorTemperatureChangetemperature
VoltageInputSensorChangesensorValue, sensorUnit
VoltageChangevoltage
VoltageOutput--
VoltageRatioInputSensorChangesensorValue, sensorUnit
VoltageChangevoltageRatio

We queue triggers and fire them when FileMaker is not busy. If the device sends too many events, we may discard in-between ones and only deliver the last event. This way you can process measurements as fast as you can, but we don't overload FileMaker.


With plugin version 6.0 or newer the script name can be a script ID number. In that case the plugin queries the script name for the given script ID. This allows to call scripts by ID and avoid problems if scripts are later renamed.

Notice: FileMaker 19.2 adds a fmplugin extended privileges. If you have such an extended privileges to allow the plugin to trigger scripts, you need to grant permissions for it. If such a privilege is not defined, the plugin is allowed to trigger scripts. See FileMaker product documentation for details.

Examples

Set attach and detach script triggers:

Set Variable [ $r ; Value: MBS( "Phidget.SetScriptTrigger"; $$phidget; "Attach"; Get(FileName); "Attached" ) ]
Set Variable [ $r ; Value: MBS( "Phidget.SetScriptTrigger"; $$phidget; "Detach"; Get(FileName); "Detached" ) ]

Set trigger for temperature changing

Set Variable [ $r ; Value: MBS( "Phidget.SetProperty"; $phidget; "DataInterval"; 1000 ) ]
Set Variable [ $r ; Value: MBS( "Phidget.SetProperty"; $phidget; "TemperatureChangeTrigger"; ,1 ) ]
Set Variable [ $r ; Value: MBS( "Phidget.SetScriptTrigger"; $phidget; "TemperatureChange"; Get(FileName); "TemperatureChange" ) ]

Set IlluminanceChange trigger:

Set Variable [ $r ; Value: MBS( "Phidget.SetProperty"; $phidget; "DataInterval"; 2000 ) ]
Set Variable [ $r ; Value: MBS( "Phidget.SetProperty"; $phidget; "IlluminanceChangeTrigger"; 10 ) ]
Set Variable [ $r ; Value: MBS( "Phidget.SetScriptTrigger"; $phidget; "IlluminanceChange"; Get(FileName); "IlluminanceChange" ) ]

Set HumidityChange trigger:

Set Variable [ $r ; Value: MBS( "Phidget.SetProperty"; $phidget; "DataInterval"; 2000 ) ]
Set Variable [ $r ; Value: MBS( "Phidget.SetProperty"; $phidget; "HumidityChangeTrigger"; 1 ) ]
Set Variable [ $r ; Value: MBS( "Phidget.SetScriptTrigger"; $phidget; "HumidityChange"; Get(FileName); "HumidityChange" ) ]

See also

Example Databases

Blog Entries

This function is free to use.

Created 16th August 2023, last changed 12nd January 2024


Phidget.SetProperty - Phidget.SetTag