经过二天我初步的调试下能运行了,并且可是查到符合条件的数据并执行下面的代码:可就是一执行完就当机,程序死了(应是进入了死循环,不动了),但是又看不出那里进入的.调整后的全部的代码如下:请大家帮我看一下,我只取了前面一段调试(后面是相类似的4嵌套循环),如果通过后面自也行,这段问题如上讲:
procedure Tformain.Timer1Timer(Sender: TObject);
var
sendno,sendmes:string;
n,i:integer;
titem:tlistitem;
begin
with datamodule1.adotimes do
begin
close;
sql.Clear;
sql.Add('select * from timesend');
open;
//while not eof do
// begin(从这里开始,下面的四个循环都同下面代码,故去掉这个判断来调试第一段)
if fieldbyname('style').AsString=timesendfrm.ComboBox1.Items.Strings[0] then
begin
close;
sql.Clear;
sql.Add('select * from timesend where style='+quotedstr(timesendfrm.ComboBox1.Items.Strings[0]));
open;
while not eof do
begin
if (fieldbyname('date').AsString=datetostr(date())) and (copy(fieldbyname('time').AsString,12,7)=timetostr(time())) then
begin
sendno:=fieldbyname('gsmno').AsString;
sendmes:=fieldbyname('message').AsString;
sendstatu:=fnGetStatus(StrToIntDef(copy(form1.ComboBox3.Text,1,pos(',',form1.ComboBox3.Text)-1),-1));
if sendstatu>=8 then
begin
if form1.ComboBox3.ItemIndex=0 then
i :=fnSendMsg(-1,pchar(fieldbyname('gsmno').AsString),pchar(fieldbyname('message').AsString))
else
i :=fnSendMsg(StrToIntDef(copy(form1.ComboBox3.Text,1,pos(',',form1.combobox3.Text)-1),-1),pchar(fieldbyname('gsmno').asstring),pchar(fieldbyname('message').asstring));
with datamodule1.adosendmess do
begin
close;
sql.Clear;
sql.Add('select *from sendmess');
open;
append;
case i of
0..255:begin
..............
end;
-1 : begin
..............
end;
else
begin
................
end;
end;
end ;
end
else
begin
messagebox(self.Handle,pchar(fsf),pchar(gsf),mb_ok or mb_iconerror);
end;
end;
// showmessage(fieldbyname('time').AsString);这时用showmessage可以找到所有数据;显示不
当机,但只要条件一成立就当机
next;
end;
end;
end;
end;
大家帮我看一下,为了这个定时的功能搞了近一个星期了,急啊,拜托大家看一看,提一提,给我一点启示,或直接帮我指出问题出在那里,那将感谢不尽。
procedure Tformain.Timer1Timer(Sender: TObject);
var
sendno,sendmes:string;
n,i:integer;
titem:tlistitem;
begin
with datamodule1.adotimes do
begin
close;
sql.Clear;
sql.Add('select * from timesend');
open;
//while not eof do
// begin(从这里开始,下面的四个循环都同下面代码,故去掉这个判断来调试第一段)
if fieldbyname('style').AsString=timesendfrm.ComboBox1.Items.Strings[0] then
begin
close;
sql.Clear;
sql.Add('select * from timesend where style='+quotedstr(timesendfrm.ComboBox1.Items.Strings[0]));
open;
while not eof do
begin
if (fieldbyname('date').AsString=datetostr(date())) and (copy(fieldbyname('time').AsString,12,7)=timetostr(time())) then
begin
sendno:=fieldbyname('gsmno').AsString;
sendmes:=fieldbyname('message').AsString;
sendstatu:=fnGetStatus(StrToIntDef(copy(form1.ComboBox3.Text,1,pos(',',form1.ComboBox3.Text)-1),-1));
if sendstatu>=8 then
begin
if form1.ComboBox3.ItemIndex=0 then
i :=fnSendMsg(-1,pchar(fieldbyname('gsmno').AsString),pchar(fieldbyname('message').AsString))
else
i :=fnSendMsg(StrToIntDef(copy(form1.ComboBox3.Text,1,pos(',',form1.combobox3.Text)-1),-1),pchar(fieldbyname('gsmno').asstring),pchar(fieldbyname('message').asstring));
with datamodule1.adosendmess do
begin
close;
sql.Clear;
sql.Add('select *from sendmess');
open;
append;
case i of
0..255:begin
..............
end;
-1 : begin
..............
end;
else
begin
................
end;
end;
end ;
end
else
begin
messagebox(self.Handle,pchar(fsf),pchar(gsf),mb_ok or mb_iconerror);
end;
end;
// showmessage(fieldbyname('time').AsString);这时用showmessage可以找到所有数据;显示不
当机,但只要条件一成立就当机
next;
end;
end;
end;
end;
大家帮我看一下,为了这个定时的功能搞了近一个星期了,急啊,拜托大家看一看,提一提,给我一点启示,或直接帮我指出问题出在那里,那将感谢不尽。
beginnext;
end;
的运行还是正常的,并用showmessage(fieldbyname('time').AsString)检测过相关的数据和运行,在这一段是应是正常的,数据一个不少的显示,且也不会当机,现在也不知是问题出现在那里
因为,你是在Time里运行
因为,你是在Time里运行