readwritecom.pas

来自「Delphi采用MSComm控件开发串口测试工具,在Windows+Delphi」· PAS 代码 · 共 57 行

PAS
57
字号
unit ReadWriteCom;

interface

//------------------------------------------------------------------------------
      procedure SendToCom1(command : string);
      procedure SendToCom2(command : string);
      procedure SendToCom3(command : string);
      procedure SendToCom4(command : string);
//------------------------------------------------------------------------------

implementation
uses Windows, Dialogs, MainFrm;
//--------------------------Com1实现--------------------------------------------
procedure SendToCom1(command : string);
begin
     if Form1.MSComm1.PortOpen then
     begin
        Form1.MSComm1.Output := OleVariant(command);
     end
     else
        ShowMessage('Com1未打开');
end;

//--------------------------Com2实现--------------------------------------------
procedure SendToCom2(command : string);
begin
     if Form1.MSComm2.PortOpen then
     begin
          Form1.MSComm2.Output := OleVariant(command);
     end
     else
          ShowMessage('Com2未打开');
end;
//------------------------------------------------------------------------------
procedure SendToCom3(command : string);
begin
     if Form1.MSComm3.PortOpen then
     begin
          Form1.MSComm3.Output := OleVariant(command);
     end
     else
          ShowMessage('Com3未打开');
end;
//------------------------------------------------------------------------------
procedure SendToCom4(command :string);
begin
     if Form1.MSComm4.PortOpen then
     begin
         Form1.MSComm4.Output := OleVariant(command);
     end
     else
         ShowMessage('Com4未打开');
end;
//------------------------------------------------------------------------------
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?