TApxComPort.AddStatusTrigger

TApxComPort

function AddStatusTrigger(const SType : Word) : Word;

Adds a status trigger of the specified type.

This method adds a status trigger of type SType, which is one of the following:

Constant
Description 
stModem
Trigger on modem status change
stLine
Trigger on line status change
stOutBuffFree
Trigger on output buffer free above level
stOutBuffUsed
Trigger on output buffer used below level
stOutSent
Trigger on any call to PutChar or PutBlock

See SetStatusTrigger for more information about these status trigger types.

If the trigger is added successfully, the function returns the handle of the trigger; otherwise, it generates an exception. The trigger is not activated until a subsequent call to SetStatusTrigger. The data associated with the trigger (such as the buffer free level for a stOutBuffFree trigger event) is supplied at that time.

The following example adds a status trigger and enables the trigger to generate an OnTriggerStatus event as soon as at least 100 bytes become free in the output buffer. Later it deactivates the trigger but does not delete it. Note that status triggers are not self restarting; the application's message handler must call SetStatusTrigger again once an event is generated.

var
StatusHandle : Word;
...
StatusHandle := ApxComPort.AddStatusTrigger(stOutBuffFree);
ApxComPort.SetStatusTrigger(StatusHandle, 100, True);
...
ApxComPort.SetStatusTrigger(StatusHandle, 0, False);

See also: RemoveTrigger, SetStatusTrigger