代码如下,//ShowMessage(IntToStr(length(s)));我把这句话不屏蔽的话可以执行下面的IF语句,屏蔽了就执行不了IF语句,是什么原因,谢谢!!!procedure TTelServerMainForm.ComPort1Trigger(CP: TObject; Msg,
  TriggerHandle, Data: Word);
var
  I : Word;
  C : Char;
  s,ALogFile : String;
  ilen: Integer;
begin
  try
  case Msg of
    APW_TRIGGERDATA :
      {got 'login', send response}
      ;
    APW_TRIGGERAVAIL :
      {extract and display/process the data}
      begin
        s:='';
        for I:= 1 to Data do
        begin
          C := ComPort1.GetChar;
          s:=s+c;
        end;
        //ShowMessage(IntToStr(length(s)));
        if   length(s) > 8 then
        begin
        //添加到日志列表里
          ALogFile := 'telinfo.txt';
          AddLogToFile(ALogFile,s);
          Diff(s);
        end;  
      end;
    APW_TRIGGERTIMER :
      {timed out waiting for login prompt, handle error}
      ;
  end;
  except
  end;
end;

解决方案 »

  1.   

    现在也取得了一定的进展,但是又有问题出来了。贴上日志文件和代码,哭~~~
    14:07:59:781  0!KA0000090011166  02231402200223140245             00000000013867656983       
    14:07:59:953                0000                      
    14:07:59:953  0   
    我加了一个控件TApdDataPack,
    设置其属性startCond=scanydata; endcond.ecpacketsize=true,packsize=132
    应该一次性接受132个字符,怎么回事呢?我是用Tapdcomport控件的Ontrigger接收数据的  APW_TRIGGERAVAIL :
          {extract and display/process the data}
          begin
            s := '';
            for I:= 1 to Data do
            begin
              if not ComPort1.CharReady then break; //add to check buffer is empty
              C := ComPort1.GetChar;
              s:=s+c;
            end;
            Memo1.Lines.add(s);
            //分析包
            if   length(s) > 8 then
            begin
            //添加到日志列表里
              ALogFile := 'telinfo.txt';
              AddLogToFile(ALogFile,s);
              Diff(s);
            end;
      

  2.   

    建议你用Sppcom控件实现,非常方便!
      

  3.   

    非常感谢Happ_QJW928已经关注的人,现在问题已经解决。