主题:[讨论]请高手帮忙分析下语句
procedure TfrmMain.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
tmpStr: Array [0..4069] of Char;
myini:tinifile;
f:string;
s,s1:string;
i,i1,i2,i3:integer;
begin
//SetLength(tmpStr,BufferLength);
tmpStr:='';
try
Move(Buffer^,PChar((@tmpStr)^),BufferLength);
except
showmessage('错误原因0');
end;
if Memo1.Visible then begin
// Memo1.Lines.Clear;
Memo1.Lines.Add(tmpStr);
if checkbox1.Checked then
begin
f:=ExtractFilePath(Paramstr(0))+'数据.txt';
myini:= tinifile.Create(f);
myini.WriteString('数据','本次有效数据',inttostr(data_i)+'条') ;
myini.WriteString('数据','数据'+inttostr(data_i),tmpstr) ;
myini.Destroy ;
data_i:=data_i+1;
end;
end;
try
DO_GPSString(tmpStr,GPSR1);
ProgressBar1.Position:=gpsr1.satinfo[1].SN ;
Label6.Caption :=inttostr(gpsr1.satinfo[1].PRN);
ProgressBar2.Position:=gpsr1.satinfo[2].SN ;
Label8.Caption :=inttostr(gpsr1.satinfo[2].PRN);
ProgressBar3.Position:=gpsr1.satinfo[3].SN ;
Label9.Caption :=inttostr(gpsr1.satinfo[3].PRN);
ProgressBar4.Position:=gpsr1.satinfo[4].SN ;
Label10.Caption :=inttostr(gpsr1.satinfo[4].PRN);
ProgressBar5.Position:=gpsr1.satinfo[5].SN ;
Label11.Caption :=inttostr(gpsr1.satinfo[5].PRN);
ProgressBar6.Position:=gpsr1.satinfo[6].SN ;
Label12.Caption :=inttostr(gpsr1.satinfo[6].PRN);
ProgressBar7.Position:=gpsr1.satinfo[7].SN ;
Label13.Caption :=inttostr(gpsr1.satinfo[7].PRN);
ProgressBar8.Position:=gpsr1.satinfo[8].SN ;
Label14.Caption :=inttostr(gpsr1.satinfo[8].PRN);
ProgressBar9.Position:=gpsr1.satinfo[9].SN ;
Label15.Caption :=inttostr(gpsr1.satinfo[9].PRN);
ProgressBar10.Position:=gpsr1.satinfo[10].SN ;
Label16.Caption :=inttostr(gpsr1.satinfo[10].PRN);
ProgressBar11.Position:=gpsr1.satinfo[11].SN ;
Label17.Caption :=inttostr(gpsr1.satinfo[11].PRN);
ProgressBar12.Position:=gpsr1.satinfo[12].SN ;
Label18.Caption :=inttostr(gpsr1.satinfo[12].PRN);
except
showmessage('错误原因1');
end;
lblJD.Caption := GPSR1.LonHemi + FloatToStr(GPSR1.Lon);
lblWD.Caption := GPSR1.LatHemi + FloatToStr(GPSR1.Lat);
lblHB.Caption := FloatToStr(GPSR1.Alt);
lblTime.Caption := GPSR1.UTC;
lblP.Caption :=FloatToStr(GPSR1.PDOP );
LBLH.Caption :=FloatToStr(GPSR1.HDOP );
lblv.Caption :=FloatToStr(gpsr1.VDOP );
s:=copy(combobox1.Text ,1,2);
s1:=combobox1.Text ;
delete(s1,1,2);
i:=pos('区',s1);
i1:=strtoint(copy(s1,1,i-1));
i2:=strtoint(copy(GPSR1.UTC,1,2));
if s='东'then
begin
i3:=i2+i1;
if i3>24 then i3:=i3-24;
Label7.Caption :=inttostr(i3)+copy(GPSR1.UTC,3,4);
end;
if s='西'then
begin
i3:=i1-i2;
// if i3>24 then i3:=i3-24;
Label7.Caption :=inttostr(i3)+copy(GPSR1.UTC,3,4);
end;
try
pbxSat.Repaint;
except
showmessage('错误原因2');
end;
end;
那位高手能帮我分析下代码啊··我有点读不懂··刚学delphi.能帮我写一下每段的意思嘛??拜托了····
BufferLength: Word);
var
tmpStr: Array [0..4069] of Char;
myini:tinifile;
f:string;
s,s1:string;
i,i1,i2,i3:integer;
begin
//SetLength(tmpStr,BufferLength);
tmpStr:='';
try
Move(Buffer^,PChar((@tmpStr)^),BufferLength);
except
showmessage('错误原因0');
end;
if Memo1.Visible then begin
// Memo1.Lines.Clear;
Memo1.Lines.Add(tmpStr);
if checkbox1.Checked then
begin
f:=ExtractFilePath(Paramstr(0))+'数据.txt';
myini:= tinifile.Create(f);
myini.WriteString('数据','本次有效数据',inttostr(data_i)+'条') ;
myini.WriteString('数据','数据'+inttostr(data_i),tmpstr) ;
myini.Destroy ;
data_i:=data_i+1;
end;
end;
try
DO_GPSString(tmpStr,GPSR1);
ProgressBar1.Position:=gpsr1.satinfo[1].SN ;
Label6.Caption :=inttostr(gpsr1.satinfo[1].PRN);
ProgressBar2.Position:=gpsr1.satinfo[2].SN ;
Label8.Caption :=inttostr(gpsr1.satinfo[2].PRN);
ProgressBar3.Position:=gpsr1.satinfo[3].SN ;
Label9.Caption :=inttostr(gpsr1.satinfo[3].PRN);
ProgressBar4.Position:=gpsr1.satinfo[4].SN ;
Label10.Caption :=inttostr(gpsr1.satinfo[4].PRN);
ProgressBar5.Position:=gpsr1.satinfo[5].SN ;
Label11.Caption :=inttostr(gpsr1.satinfo[5].PRN);
ProgressBar6.Position:=gpsr1.satinfo[6].SN ;
Label12.Caption :=inttostr(gpsr1.satinfo[6].PRN);
ProgressBar7.Position:=gpsr1.satinfo[7].SN ;
Label13.Caption :=inttostr(gpsr1.satinfo[7].PRN);
ProgressBar8.Position:=gpsr1.satinfo[8].SN ;
Label14.Caption :=inttostr(gpsr1.satinfo[8].PRN);
ProgressBar9.Position:=gpsr1.satinfo[9].SN ;
Label15.Caption :=inttostr(gpsr1.satinfo[9].PRN);
ProgressBar10.Position:=gpsr1.satinfo[10].SN ;
Label16.Caption :=inttostr(gpsr1.satinfo[10].PRN);
ProgressBar11.Position:=gpsr1.satinfo[11].SN ;
Label17.Caption :=inttostr(gpsr1.satinfo[11].PRN);
ProgressBar12.Position:=gpsr1.satinfo[12].SN ;
Label18.Caption :=inttostr(gpsr1.satinfo[12].PRN);
except
showmessage('错误原因1');
end;
lblJD.Caption := GPSR1.LonHemi + FloatToStr(GPSR1.Lon);
lblWD.Caption := GPSR1.LatHemi + FloatToStr(GPSR1.Lat);
lblHB.Caption := FloatToStr(GPSR1.Alt);
lblTime.Caption := GPSR1.UTC;
lblP.Caption :=FloatToStr(GPSR1.PDOP );
LBLH.Caption :=FloatToStr(GPSR1.HDOP );
lblv.Caption :=FloatToStr(gpsr1.VDOP );
s:=copy(combobox1.Text ,1,2);
s1:=combobox1.Text ;
delete(s1,1,2);
i:=pos('区',s1);
i1:=strtoint(copy(s1,1,i-1));
i2:=strtoint(copy(GPSR1.UTC,1,2));
if s='东'then
begin
i3:=i2+i1;
if i3>24 then i3:=i3-24;
Label7.Caption :=inttostr(i3)+copy(GPSR1.UTC,3,4);
end;
if s='西'then
begin
i3:=i1-i2;
// if i3>24 then i3:=i3-24;
Label7.Caption :=inttostr(i3)+copy(GPSR1.UTC,3,4);
end;
try
pbxSat.Repaint;
except
showmessage('错误原因2');
end;
end;
那位高手能帮我分析下代码啊··我有点读不懂··刚学delphi.能帮我写一下每段的意思嘛??拜托了····