ThbTapiLine.SetRequestNote
Unit: hbTapi
 

Everytime, hbTapi calls an asynchronous TAPI function, an internal request object will be created. This object holds information like the request ID, the request type, a timeout value and the participating objects (e.g. calls). SetRequestNode can be used to store your own information within the request object. Especially if you are using the asynchronus mode of hbTapi, this function is very helpfull. It provides you with a simple possibility to bundle information with a request identified by its request ID.

Declaration

procedure SetRequestNote(RequestID: Integer; Ident: String; Value: Variant);

Parameters

RequestID
 ID of an existing request. Use ThbTapiLine.LastRequestID to get the RequestID of an asynchronous function call.
Ident

Identifier of the needed information. There are two kinds of identifiers: internal and user defined. All Internal identifiers are beginning with a '&' like '&TapiRequest' and can't be set with this procedure.

User defined identifiers must start with a character or an underscore and must not contain spaces. There can be characters, numbers or underscores following the first character. An Identifier is not case sensitive.

Valid identifiers are: Value1, Time, Count_1

Value
Value as a variant you want to store with the request. You are able to tranfer any type a variant accepts.

Remarks

The request exists between the calling of the initiating method resp. setting the initiating and the corresponding reply event (ThbTapiPhone.OnTapiReply). Calling SetRequestNote with an old request id will raise an exception.

The following example shows how to store an information together with the request and how to retrieve it back in ThbTapiLine.OnTapiReply. The number of created calls are store in the variable FNumMakeCall and ist given to request. ThbTapiLine.OnTapiReply this information is retrieved and used to display a message dialog.

interface
uses hbTapi, tapi, ...

procedure TForm1.DoMakeCall(Sender: TObject);
begin
  try
    hbTapiLine1.MakeCall(EditPhoneNo.Text);
    inc(FNumMakeCall);
    hbTapiLine1.SetRequestNote(hbTapiLine1.LastRequestID, 'NumMakeCall', FNumMakeCall);
  except
    on E:EhbTapiError do
      MessageDlg('MakeCall failed! ' + E.Message, mtError, [mbok], 0);
  end;
end;

procedure TForm1.hbTapiLine1TapiReply(Sender: TObject; RequestID, ReplyCode: Cardinal);
begin
  if (ReplyCode <> 0) then
  begin
    if hbTapiLine1.GetRequestNote(RequestID, '&TapiRequest') = TAPIREQUEST_LINEMAKECALL then
      MessageDlg(Format('TapiReply: MakeCall #%d failed! %s', [Integer(hbTapiLine1.GetRequestNote(RequestID, 'NumMakeCall')),
         GetTapiErrorMessage(ReplyCode)]), mtError, [mbOK], 0);
    else
      MessageDlg('TapiReply: Error' +#13 + #10 + GetTapiErrorMessage(ReplyCode), mtError, [mbOK], 0);
  end
end;