RPC Broker TParamRecord Example

From VistApedia
Jump to: navigation, search

TParamRecord Example

The following program code demonstrates how you can use a TParamRecord variable to save a copy of a single parameter of a TRPCBroker component. This example assumes that prior to calling this procedure, a TRPCBroker variable has been created and some parameters have been set up. Pay close attention to how properties are copied one at a time. This is the only way that a separate copy could be created. If you try to simply assign one of the TRPCBroker parameters to the TParamRecord variable, you’ll simply re-point the TParamRecord variable to that parameter:


   procedure TForm1.Button1Click(Sender: TObject);
   var
     ParamRecord: TParamRecord;
   begin
     {Create ParamRecord. Make Form1 its owner}
     ParamRecord := TParamRecord.Create(Form1);
     {Store properties one at a time}
     ParamRecord.Value := RPCBroker.Param[0].Value;
     ParamRecord.PType := RPCBroker.Param[0].PType;
     {This is how to copy a Mult}
     ParamRecord.Mult.Assign(RPCBroker.Param[0].Mult);
   end;