📄 pc+
字号:
if pos('OK',recivestr)>0 then
if pos(',',recivestr)>0 then
begin
intno:=pos('+CSQ:',recivestr);
if (intno>0) and (pos('CSQ',recivestr)>0) then
begin
temp:=copy(recivestr,intno+6,2);
edit1.Text:=temp;
refresh();
end;
viewreciveword();
end
else
if pos('CMGS',recivestr)>0 then
begin
viewreciveword();
mulitsendstop:=false;
end
else
if (pos('AT+CMGL',recivestr)>0) and (pos('OK',recivestr)>0) then
viewreciveword
else
if (pos('AT+CMGR',recivestr)>0) and (pos('OK',recivestr)>0) then
viewreciveword
else
if (pos('AT+CMGI',recivestr)>0) and (pos('OK',recivestr)>0) then
viewreciveword
else
if (pos('AT+CMGD',recivestr)>0) and (pos('OK',recivestr)>0) then
viewreciveword;
//自动收取短信
if (pos('SM',ReciveStr) > 0) And (autoreceive = 1) then
begin
ReadShortLetter := True;
intno := pos('SM',ReciveStr);
rno := copy(ReciveStr, intno + 4, 2);
edit4.Text := Trim(rno);
MSComm1.Output := 'AT+CMGR=' + '' + rno +chr(13);
ReciveStr := '';
Sendstr := 'AT+CMGR=' + rno +chr(13);
ViewSendWord();
showmessage('来新短信了');
End;
if (length(recivestr)=8) and (pos('AT',recivestr)>0) and (pos('OK',recivestr)>0) then
viewreciveword();
end;
end;
//发送数据
procedure TForm1.senddata();
begin
recivestr:='';
if pduorder=false then
begin
MSComm1.Output :=senddatastr+widechar($1A);
sendstr:=senddatastr+widechar($1A);
end
else
begin
MSComm1.Output :=trim(strunicode)+widechar($1A);
sendstr:=trim(strunicode)+widechar($1A);
end;
viewsendword();
end;
procedure TForm1.viewsendword();
begin
richedit1.text:=richedit1.text+timetostr(time())+'发送:'+' '+sendstr+chr(10);
end;
procedure TForm1.viewreciveword();
begin
richedit2.text:='';
if readshortletter then
if pduorder then
richedit2.text:=richedit2.text+' '+readunicode(trim(recivestr))+chr(13)
else
richedit2.text:=richedit2.text+' '+readtext(trim(recivestr))+chr(13)
else
richedit2.text:=richedit2.text+' '+recivestr+chr(13);
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
sendsca:=combobox1.text;
end;
procedure TForm1.ComboBox1Click(Sender: TObject);
begin
sendsca:=combobox1.Text;
end;
procedure TForm1.ComboBox2Click(Sender: TObject);
var
temp:string;
begin
readshortletter:=false;
if (combobox2.text='Text') then
begin
temp:=MSComm1.Input ;
pduorder:=false;
MSComm1.Output :='AT+CMGF=1'+chr(13);
end
else
begin
temp:=MSComm1.Input ;
pduorder:=true;
MSComm1.Output:='AT+CMGF=0'+chr(13);
end;
end;
procedure TForm1.RichEdit1Change(Sender: TObject);
begin
{ richedit1.Text:=''; }
end;
procedure TForm1.RichEdit2Change(Sender: TObject);
begin
richedit3.Text:=richedit2.Text;
//richedit2.text:='';
end;
function TForm1.readtext(tempstr:widestring):widestring;
var
i:integer;
j:integer;
strbcd:string;
temp:string;
zfvalue:longint;
shortletter:string;
sumcount:double;
zf:string;
begin
temp:=trim(rightstr(tempstr,length(tempstr)-pos(',',tempstr)));
temp:=rightstr(temp,length(temp)-pos(chr(13),temp)-1);
temp:=leftstr(trim(temp),pos(chr(13),trim(temp)));
temp:=trim(temp);
i:=1;
while i<= length(temp)-1 do
begin
shortletter:=shortletter+widechar(strtoint('$'+copy(temp,i,4)));
i:=i+4;
end;
readtext:=shortletter;
end;
function TForm1.readunicode(tempstr:widestring):widestring;
var
i,j:integer;
strbcd,temp,temp1,temp2,temp3,temp4:string;
zfvalue:longint;
shortletter:string;
sumcount:double;
zf:string;
shortlen:string;
begin
temp1:=tempstr;
temp1:=rightstr(tempstr,length(tempstr)-(pos(',,',tempstr)+1));
shortlen:=leftstr(temp1,(pos(chr(13),temp1)-1));
temp2:=rightstr(temp1,length(temp1)-pos(chr(13),temp1));
temp3:=leftstr(trim(temp2),pos(chr(13),temp2)-1);
temp3:=trim(temp3);
if strtoint(shortlen) mod 2 <> 0 then
shortlen:=inttostr(strtoint(shortlen)-1);
if pos('0811',temp3)> 0 then
temp4:=rightstr(trim(temp3),strtoint(shortlen)*2-36)
else
temp4:=rightstr(trim(temp3),(strtoint(shortlen)-18)*4);
temp4:=trim(temp4);
i:=1;
while i<= length(temp4) do
begin
shortletter:=shortletter+widechar(strtoint('$'+copy(temp4,i,4)));
i:=i+4;
end;
readunicode:=shortletter;
end;
function TForm1.getunicode(tempstr:widestring):widestring;
var
tempsendphone:string;
tempscaphone:string;
intlen:integer;
i:integer;
strbcd:string;
temp,tempsca:string;
strlen:string;
letterlen:string;
strmove,strright,strunicode:string;
begin
//服务中心号码
tempsca:=sendsca;
if pos(tempsca,chr(13))<>0 then
tempsca:=leftstr(tempsca,length(tempsca)-2);
intlen:=length(tempsca);
if intlen>0 then
begin
i:=1;
while i<=intlen do
begin
strbcd:=trim(copy(tempsca,i,2));
if length(strbcd)=2 then
temp:=temp+rightstr(strbcd,1)+leftstr(strbcd,1)
else
temp:=temp+'F'+leftstr(strbcd,1);
i:=i+2;
end;
tempsca:=temp;
end;
tempsca:='089168'+tempsca+'11000B81';
//发送电话号码
tempsendphone:=sendphone;
if pos(tempsendphone,chr(13))<>0 then
tempsendphone:=leftstr(tempsendphone,length(tempsendphone)-2);
intlen:=length(tempsendphone);
temp:='';
if intlen>0 then
begin
i:=1;
while i<=intlen do
begin
strbcd:=trim(copy(tempsendphone,i,2));
if length(strbcd)=2 then
temp:=temp+rightstr(strbcd,1)+leftstr(strbcd,1)
else
begin
temp:=temp+'F'+leftstr(strbcd,1);
break;
end;
i:=i+2
end;
tempsendphone:=temp;
end;
//发送电话号码
strlen:=inttohex(length(trim(tempstr))*2,0);
case length(strlen) of
1:letterlen:='A80'+strlen;
2:letterlen:='A8'+strlen;
end;
//发送数据长度
if length(tempstr)>100 then
tempstr:=leftstr(tempstr,1000);
intlen:=length(tempstr);
if intlen>0 then
begin
for i:=1 to intlen do
begin
strbcd:=trim(copy(tempstr,i,1));
if strbcd='' then
strbcd:=' ';
strbcd:=inttohex(ord(widestring(strbcd)[1]),0);
if length(strbcd)<3 then
case length(strbcd) of
1:strmove:=strmove+'000'+strbcd;
2:strmove:=strmove+'00'+strbcd;
end
else
strmove:=strmove+strbcd;
end;
tempstr:=strmove;
end;
//得到数据UNICODE码
getunicode:=tempsca+tempsendphone+'0008'+letterlen+tempstr;
strunicode:=tempsca+tempsendphone+'0008'+letterlen+tempstr;
//
strright:=rightstr(trim(strunicode),length(strunicode)-18);
txtletterlen:=length(trim(strright)) div 2;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
mscomm1.PortOpen :=false;
close;
end;
procedure TForm1.CheckListBox1Click(Sender: TObject);
begin
edit2.text:=checklistbox1.items[checklistbox1.itemindex];
REFRESH();
end;
procedure TForm1.N1Click(Sender: TObject);
var
i,j:longint;
delarray:array of longint;
delcount:longint;
begin
checklistbox1.DeleteSelected ;
for i:=0 to checklistbox1.Count-1 do
begin
if checklistbox1.Checked[i] then
begin
setlength(delarray,delcount);
delcount:=delcount+1;
end;
end
end;
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
autoreceive:=0;
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
autoreceive:=1;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -