📄 upu.pas.~13~
字号:
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:='+8613010112500'; //短信中心
lstPhone :=TStringList.Create; //电话号码
txtInitR(); //读初始化文件
end;
procedure txtInitR(); //读初始化文件 Init.dat
var
fileName : string;
str : string;
F : TextFile;
i : integer;
bolPhone :boolean; //是否存在电话号码标志
sPhone,sName:string;
begin
fileName := ExtractFilePath(Application.ExeName) +'msgInit.dat';
lstPhone.Clear;
if FileExists(fileName) then begin
bolPhone :=false; //是否存在电话号码标志
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 iComBaud :=1200
else if Trim(str)='2400' then iComBaud :=2400
else if Trim(str)='4800' then iComBaud :=4800
else if Trim(str)='9600' then iComBaud :=9600
else iComBaud :=9600;
end else if i=3 then begin //短信中心
if (length(Trim(str))=11)or(length(Trim(str))=14) then
sMsgCentID:=Trim(str)
else sMsgCentID:='+8613010112500'; //短信中心
end else if i=4 then begin //
end else if i=5 then begin //
end else if i=6 then begin //
end else if i=7 then begin //
end else if i=8 then begin //
end else if i=9 then begin //
end else if i=10 then begin //
if Trim(str)='PhoneAndName' then bolPhone :=true; //是否存在电话号码标志
end else if i<=30 then begin //最多20个电话号码
if Trim(str)='end' then break;
sPhone :=Trim(split_2(str,':'));
sName :=Trim(split_2(str,':',false));
if (length(sPhone)=11)and(length(sName)>2) then begin
lstPhone.Add( sPhone+':'+sName);
end;
end else if i>30 then begin
break;
end;
end;
CloseFile(F); // 关闭文件
end;
end;
procedure txtInitW(); //写初始化文件 Init.dat
var
fileName : string;
F : TextFile;
i : integer;
begin
fileName := ExtractFilePath(Application.ExeName) +'msgInit.dat';
AssignFile(F, fileName); //后面可以使用F变量对文件进行操作
Rewrite(F); //以可写方式打开文件。不存在,创建。存在,覆盖。
Append(F); //以追加的方式打开文件
Writeln(F, 'com'+IntToStr(iComPort)); //串口
Writeln(F, IntToStr(iComBaud)); //波特率
Writeln(F, sMsgCentID); //短信中心
Writeln(F, '----'); //4到9为保留
Writeln(F, '----'); //4到9为保留
Writeln(F, '----'); //4到9为保留
Writeln(F, '----'); //4到9为保留
Writeln(F, '----'); //4到9为保留
Writeln(F, '----'); //4到9为保留
Writeln(F, 'PhoneAndName'); //是否存在电话号码标志
for i:=0 to lstPhone.Count-1 do begin
Writeln(F, lstPhone[i]); //最多20个电话号码
end;
Writeln(F, 'end'); //结束标志
CloseFile(F); // 关闭文件
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 + -