//SEND "write command" to PLC
procedure TForm1.LbSpeedButton2Click(Sender: TObject);
var B:TBytes;
var Buffer: array [0..99] of byte;
res: string;
begin
//受信
SetLength(B, 0);
IdTCPClient1.IOHandler.ReadBytes(TIdBytes(B), -1); //uses idGlobal
res:=BytesToString(B); //Indy has BytesToString() and ToBytes() functions for converting between String and TIdBytes
//授信文字列
Edit7.Text := '('+_StrToHex(res)+')';
end;
//SEND "read command" to PLC
procedure TForm1.LbSpeedButton3Click(Sender: TObject);
var B:TBytes;
Buffer: array [0..99] of byte;
res: string;
begin
//受信
SetLength(B, 0);
IdTCPClient1.IOHandler.ReadBytes(TIdBytes(B), -1); //uses idGlobal
res:=BytesToString(B); //Indy has BytesToString() and ToBytes() functions for converting between String and TIdBytes