When a user selects a terminal type entry in the list box, the OnClick event is triggered. The new ZxxxTT RETRIEVE RPC can be called from that OnClick event, as a replacement for the code there that simply displays the ien of any selected record.
To use the ZxxxTT RETRIEVE RPC to display fields from a selected terminal type:
|
Terminal Type Field |
Add a TEdit component named: | Add a Label with the Caption: |
| .01 | Name | Name: |
| 1 | RightMargin | Right Margin: |
| 2 | FormFeed | Form Feed: |
| 3 | PageLength | Page Length: |
| 4 | BackSpace | Back Space: |
| 6 | OpenExecute | Open Execute: |
| 7 | CloseExecute | Close Execute: |
a. Set RCPBroker1's RemoteProcedure property to ZxxxTT RETRIEVE.
b. Pass the ien of the selected terminal type to the RPC, using the TRPCBroker's runtime Param property. Pass the ien in the Value property, i.e. RPCBroker1.Param[0].Value.
c. The PType for the ien parameter should be passed in RPCBroker1.Param[0].PType. Possible types are literal, reference and list. In this case, to pass in an ien, the appropriate PType is literal.
d. Call RPCBroker1's Call method (in a try...except exception handler block) to invoke the ZxxxTT RETRIEVE RPC.
e. Set the appropriate pieces from each of the three Results nodes into each of the TEdit boxes corresponding to each returned field.
The code for the OnClick event handler should look like the following:
procedure TForm1.ListBox1Click(Sender: TObject);
var
ien: String;
begin
if (ListBox1.ItemIndex <> -1) then
begin {displayitem}
ien:=piece(TermTypeList[ListBox1.ItemIndex],'^',1);
RPCBroker1.RemoteProcedure:='ZxxxTT RETRIEVE';
RPCBroker1.Param[0].Value := ien;
RPCBroker1.Param[0].PType := literal;
try
begin {call code}
RPCBroker1.Call;
Name.Text:=piece(RPCBroker1.Results[0],'^',1);
RightMargin.Text:=piece(RPCBroker1.Results[0],'^',2);
FormFeed.Text:=piece(RPCBroker1.Results[0],'^',3);
PageLength.Text:=piece(RPCBroker1.Results[0],'^',4);
BackSpace.Text:=piece(RPCBroker1.Results[0],'^',5);
OpenExecute.Text:=RPCBroker1.Results[1];
CloseExecute.Text:=RPCBroker1.Results[2];
end; {call code}
except
On EBrokerError do
ShowMessage('A problem was encountered communicating with the server.');
end; {try}
end; {displayitem}
end;