function TCom_wry.Bohao():Boolean;
var
  i,j,l:integer;
begin
  m_SendBuf[0]:=$61;
  m_SendBuf[1]:=$74;
  m_UseSendBufLen:=2;
  for l:=1 to 1 do
   begin
     Lib_Com.Com_wry.WriteComPort();//写串口数据
     Sleep(500);
     if Lib_Com.Com_wry.ReadComPort() then读串口数据
        begin
          if (m_ReadBuf[2]=$4f) and (m_ReadBuf[3]=$4b) then
          begin
           showmessage('Modem正常');
            m_SendBuf[0]:=$61;
            m_SendBuf[1]:=$74;
            m_SendBuf[2]:=$64;
            m_SendBuf[3]:=$74;
            m_SendBuf[4]:=$38;
            m_SendBuf[5]:=$38;
            m_SendBuf[6]:=$36;
            m_SendBuf[7]:=$31;
            m_SendBuf[8]:=$35;
            m_SendBuf[9]:=$31;
            m_SendBuf[10]:=$38;
            m_SendBuf[11]:=$31;
            m_SendBuf[12]:=$0d;
            m_SendBuf[13]:=$0a;
            m_UseSendBufLen:=14;
            for i:=1 to 1 do
            begin
              Lib_Com.Com_wry.WriteComPort();//写
              Sleep(23000);
              if ((m_ReadBuf[0]=$0d) and (m_ReadBuf[1]=$0a) then
              begin
                ShowMessage('连接成功');
                Result:=True;
              end
              else
              Result:=false;
              end;
            end;
          end;
        end;
   end;
end;我真的多了一个end;吗?搞不懂啊..应该没多吧..

解决方案 »

  1.   

    if ((m_ReadBuf[0]=$0d) and (m_ReadBuf[1]=$0a) then
                  begin
                    ShowMessage('连接成功');
                    Result:=True;
                  end
                  else
                  Result:=false;
    -->              end;呵呵
      

  2.   

    if ((m_ReadBuf[0]=$0d) and (m_ReadBuf[1]=$0a) then//少了个)括号吧
                  begin
                    ShowMessage('连接成功');
                    Result:=True;
                  end
      

  3.   

    不是说过了吗.
      去掉一个end;得出来的结果就不正确了..
    再说了.
     
    if *** then
    begin
    *
    *
    *
    end
    else

    *
    *
    end;
    这样的语法有错吗?
      

  4.   

    if *** then
    begin
    *
    *
    *
    end
    else

    *
    *
    end;你说呢?呵呵
      

  5.   

    TO hellolongbin(一个人[终不似 少年游])   但我用了if then
              end
              else
              end;
    这样的语句.肯定是要多一个end出来的啊.这个if 里面的end 是没有分号的...
      

  6.   

    if *** then
    这样才对,年轻人,begin和end是配对的begin
    *
    *
    *
    end
    else
    begin

    *
    *
    end;
      

  7.   

    if *** then
    begin
    *
    *
    *
    end
    else
    begin

    *
    *
    end;唉,老了,怎么把字都打到语句中间了
      

  8.   

    if *** then
    begin
    *
    *
    *
    end
    else

    *
    *
    end;
    但我看别人的代码和看书上的..都是这样写的啊...
      

  9.   

    function TCom_wry.Bohao():Boolean;
    var
      i,j,l:integer;
    begin
      m_SendBuf[0]:=$61;
      m_SendBuf[1]:=$74;
      m_UseSendBufLen:=2;
      for l:=1 to 1 do
       begin/////AA
         Lib_Com.Com_wry.WriteComPort();//写串口数据
         Sleep(500);
         if Lib_Com.Com_wry.ReadComPort() then读串口数据
            begin/////BB
              if (m_ReadBuf[2]=$4f) and (m_ReadBuf[3]=$4b) then
              begin/////CC
               showmessage('Modem正常');
                m_SendBuf[0]:=$61;
                m_SendBuf[1]:=$74;
                m_SendBuf[2]:=$64;
                m_SendBuf[3]:=$74;
                m_SendBuf[4]:=$38;
                m_SendBuf[5]:=$38;
                m_SendBuf[6]:=$36;
                m_SendBuf[7]:=$31;
                m_SendBuf[8]:=$35;
                m_SendBuf[9]:=$31;
                m_SendBuf[10]:=$38;
                m_SendBuf[11]:=$31;
                m_SendBuf[12]:=$0d;
                m_SendBuf[13]:=$0a;
                m_UseSendBufLen:=14;
                for i:=1 to 1 do
                begin/////DD
                  Lib_Com.Com_wry.WriteComPort();//写
                  Sleep(23000);
                  if ((m_ReadBuf[0]=$0d) and (m_ReadBuf[1]=$0a) then
                  begin/////EE
                    ShowMessage('连接成功');
                    Result:=True;
                  End/////EE
                  else
                  Result:=false;
              //  end;  //
                end;/////DD
              end;/////CC
            end;/////BB
       end;/////AA
    end;
      

  10.   

    不可能...完全不可能.  我试了N次了...还是不行..要不然就是多一个end;
    要不然就是结果不对...
      

  11.   

    begin
    end
    是配对的,if    then   但后面没有end