RPC HELP TRPCBroker Example

From VistApedia
Jump to: navigation, search

TRPCBroker Example

The following example demonstrates how a TRPCBroker component can be used to connect to the VistA M Server, execute various remote procedures, return the results and finally disconnect from the server. This example assumes that a TRPCBroker component already exists on the form as brkrRPCBroker1:

   procedure TForm1.Button1Click(Sender: TObject);
   begin
     try
       {connect to the server}
       brkrRPCBroker1.Connected := True;
       //assign RPC name
       brkrRPCBroker1.RemoteProcedure := 'SOME APPLICATION RPC';
       {make the call}
       brkrRPCBroker1.Call;
       {display results}
       ListBox1.Items := brkrRPCBroker1.Results;
       {disconnect from the server}
       brkrRPCBroker1.Connected := False;
     except
       //put error handling code here
     end;
   end;