⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upu.pas.~11~

📁 用串口发送手机短信 需要GSM Mode设备
💻 ~11~
字号:
unit uPU;

interface

uses
  Windows, Forms, SysUtils, Classes;

procedure puSubQJBL();  //初始化全局变量
procedure txtInitR();  //读初始化文件 Init.dat
function split_2(str,subStr:string;flag:boolean=true):string;

//声明全局变量
var
  LogSevr, LogBase, LogUser, LogPasd, LogBaseCur: string;
  dbPath, dbPathSql, aspPath : string;  //数据库路径

  iComPort, iComBaud :Word;  //串口, 波特率
  sMsgCentID:string;    //短信中心
  lstPhone :TStrings;   //电话号码

const
  cstLogPasd:string='LuYi16.com$763';
  mdbPsd : string='OnlyLove';

implementation

procedure puSubQJBL();
//初始化全局变量
begin
  LogSevr   := '(local)\gsql';     //SQL服务器  (local)\gsql
  LogBase   := 'kjRY_seei';    //命令字节间的等待时间    最小值为5
  LogUser   := 'sa';   //发送命令的等待时间      最小值为350
  LogPasd   := cstLogPasd;

  iComPort :=1;         //串口
  iComBaud :=9600;      //波特率
  sMsgCentID:='';       //短信中心
  lstPhone :=TStringList.Create;  //电话号码
  lstPhone.Add('13552443072');

  txtInitR();   //读初始化文件
end;

procedure txtInitR();  //读初始化文件 Init.dat
var
  fileName : string;
  str : string;
  F : TextFile;
  i : integer;
begin
  fileName := ExtractFilePath(Application.ExeName) +'msgInit.dat';
  if FileExists(fileName) then begin
    AssignFile(F, fileName); //后面可以使用F变量对文件进行操作
    Reset(F);   //以只读方式打开文件
    i:=0;
    while not EOF(F) do
    begin
       Readln(F, str);  Inc(i);
       if i=1 then begin               //串口
          if Trim(str)='com2' then  iComPort :=2
          else if Trim(str)='com3' then  iComPort :=3
          else if Trim(str)='com4' then  iComPort :=4
          else if Trim(str)='com5' then  iComPort :=5
          else if Trim(str)='com6' then  iComPort :=6
          else  iComPort :=1;
       end else if i=2 then begin      //波特率
          if Trim(str)='1200' then  iComPort :=1200
          else if Trim(str)='2400' then  iComPort :=2400
          else if Trim(str)='4800' then  iComPort :=4800
          else if Trim(str)='9600' then  iComPort :=9600
          else  iComPort :=9600;
       end else if i=3 then begin      //短信中心
          if (length(Trim(str))=11)or(length(Trim(str))=14) then
            sMsgCentID:=Trim(str)
          else sMsgCentID:='';
       end else if i=4 then begin      //

       end else if i=5 then begin      //

       end else if i=6 then begin      //下井超时时间

       end;
    end;

    CloseFile(F); // 关闭文件
  end;
end;

function split_2(str,subStr:string;flag:boolean=true):string;
{根据 字符串subStr拆分字符串str为两部分
没有分隔时返回全串, 当flag=true时返回左边
}
var
  rtn : string;
  nPos, Len : integer;   //Len记录subStr的长度
begin
  nPos := AnsiPos(subStr,str);
  Len := length(subStr);
  if nPos<>0 then begin
      if flag then
          rtn:=copy(str,1,nPos-1)
      else
          rtn:=copy(str,nPos+len,length(str));
  end else begin
      rtn:=str;
  end;
  Result := rtn;
end;

end.

⌨️ 快捷键说明

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