Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Strange if statement missing. 5 lines code (http://www.go4expert.com/forums/strange-statement-missing-5-lines-code-t16689/)

hazamin 27Mar2009 12:05

Strange if statement missing. 5 lines code
 
Hi. I use Indy component for working with pop3. ( C++ Builder)
Code

Code:

if (mess->MessageParts->Items[inindex] is TIdAttachmentFile)
        { li=lvAttachments->Items->Add();
          li->ImageIndex=0;
          li->Caption=TIdAttachmentFile(mess->MessageParts->Items[inindex])->Filename;
          li->SubItems->Add(TIdAttachmentFile(mess->MessageParts->Items[inindex])->ContentType);
          }

if (mess->MessageParts->Items[inindex] is TIdAttachmentFile) { li=lvAttachments->Items->Add(); li->ImageIndex=0; li->Caption=TIdAttachmentFile(mess->MessageParts->Items[inindex])->Filename; li->SubItems->Add(TIdAttachmentFile(mess->MessageParts->Items[inindex])->ContentType); }
raises error on first line with message "If statement missing )"
Value mess is TIdMessage type.

hazamin 27Mar2009 12:06

Strange if statement missing. 5 lines code
 
here is full listing of code

Code:

void __fastcall TForm1::sf(TObject *Sender)
{
 int inIndex;
AnsiString s;
TListItem *li;
TIdAttachment *Attachment,*Result;

if  (lv1->Items->Count==0) ShowMessage("Нет сообщений");
lvAttachments->Items->Clear();
s="";
Memo1->Clear();

if(lv1->Items->Count>0)
  {
  pop->Retrieve(lv1->Selected->Index+1, mess);
  Label2->Caption=mess->From->Text;
  Label1->Caption=mess->Recipients->EMailAddresses;
  Label3->Caption=mess->Subject;
  Label4->Caption=FormatDateTime("dd mm yyyy hh:mm:ss", mess->Date);
  Memo1->Lines->Add(mess->Body->Text);
  for(int inindex=0; inindex<mess->MessageParts->Count; inindex++)
    {

    if (mess->MessageParts->Items[inindex] is TIdAttachmentFile)
        { li=lvAttachments->Items->Add();
          li->ImageIndex=0;
          li->Caption=TIdAttachmentFile(mess->MessageParts->Items[inindex])->Filename;
          li->SubItems->Add(TIdAttachmentFile(mess->MessageParts->Items[inindex])->ContentType);
          }

    if(mess->MessageParts->Items[inindex] is TIdText)
      {
      Format(" Mime-тип для части %d : % <%s>",[inindex,mess->MessageParts->Items[inindex]->ContentType]);
      if  (mess->MessageParts->Items[inindex] is  TIdAttachmentFile)
        {
          Attachment=TIdAttachmentFile(mess->MessageParts->Items[inindex]);
          if TextIsSame(stFilename, Attachment->Filename)
            {
            Result=Attachment ;
            }
          }
        }
        Result=Null;
}  } }


listendinesh 27Mar2009 17:06

Re: Strange if statement missing. 5 lines code
 
"is" should be replaced by "=="...
Code:

if (mess->MessageParts->Items[inindex] is TIdAttachmentFile)
should be
Code:

if (mess->MessageParts->Items[inindex] == TIdAttachmentFile)

hazamin 27Mar2009 21:12

Re: Strange if statement missing. 5 lines code
 
oh, thank you people. But my compiler (C++ Builder 6.0) has no include file <IdAttachmentFile.hpp>. Compiler rise error

"unable to open include file 'IdAttachment.hpp''.
So, could you send this include file via e-mail? My e-mail is: hazamin@mail.com

Big thanks, people.


All times are GMT +5.5. The time now is 03:37.