经过二天我初步的调试下能运行了,并且可是查到符合条件的数据并执行下面的代码:可就是一执行完就当机,程序死了(应是进入了死循环,不动了),但是又看不出那里进入的.调整后的全部的代码如下:请大家帮我看一下,我只取了前面一段调试(后面是相类似的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;
大家帮我看一下,为了这个定时的功能搞了近一个星期了,急啊,拜托大家看一看,提一提,给我一点启示,或直接帮我指出问题出在那里,那将感谢不尽。

解决方案 »

  1.   

    第二个 while not eof do 循环缺少 Next;
      

  2.   

    没有少啊,在showmessage下面就是啊,如果少了就也找不到符合条件的数据,说明while not eof do 
    beginnext;
    end;
    的运行还是正常的,并用showmessage(fieldbyname('time').AsString)检测过相关的数据和运行,在这一段是应是正常的,数据一个不少的显示,且也不会当机,现在也不知是问题出现在那里
      

  3.   

    messagebox(self.Handle,pchar(fsf),pchar(gsf),mb_ok or mb_iconerror)的可能性很~~~
    因为,你是在Time里运行
      

  4.   

    messagebox(self.Handle,pchar(fsf),pchar(gsf),mb_ok or mb_iconerror)的可能性很大~~~
    因为,你是在Time里运行
      

  5.   

    dataopen,你讲的非常有道理,我也怀疑是错在这里,但是不知是为何原因,你讲和timer有冲突,但这是为何呢?怎样的改过来,这只是系统的一个提示的函数,里面的中文章的提示为“设备连接不正常”和“错误提示”两个字段,因为是简体和繁体两版本,用配置文件切换的所以这样的写,
      

  6.   

    现在已找到错的地方,不是循环的问题,也不是判断的错误,而是timeer事件与showmessage()函数的冲突问题,在timeer事件中不能就这样的用messagebox()函数(我将其换成showmessage就不会当机了,一切正常了),但我还是要用messagebox()函数啊;有谁能讲一讲这种冲突是怎样的产生的吗,怎样的处理才能正常的在timer事件中用showmessage()函数;