🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages Started by Tog Fri, 03 Sep 2004 00:12
TIdIRC's OnNames
#5402
Author: Tog
Date: Fri, 03 Sep 2004 00:12
32 lines
1654 bytes
Hi,

i'm running this code in the OnNames event:

TTeListBox *myListBox = NULL;
myListBox = FindListBox(AChannel->Name);
if (myListBox)
        {
        myListBox->Clear();
                for (int j=0; j < AUsers->Count; j++)
                        {
                        if (AChannel->Names->Objects[j] == (TObject*) 1)

myListBox->Items->Add("@"+AUsers->Items[j]->Nick);
                        else if (AChannel->Names->Objects[j] == (TObject*)
2)

myListBox->Items->Add("+"+AUsers->Items[j]->Nick);
                        else

myListBox->Items->Add(AUsers->Items[j]->Nick);
                        }
        }

I get a crash on AUsers->Count, it's not accessable it seems, nothing is
returned, so my loop just goes into an "Out of Index(some number)"...

Is this an Indy bug or am I doing something wrong?

Using Indy 9 in BCB 6.

Thanks!
Re: TIdIRC's OnNames
#5403
Author: Remy Lebeau (TeamB)
Date: Fri, 03 Sep 2004 02:29
38 lines
2003 bytes
<Tog> wrote in message news:4137b6d9$1@newsgroups.borland.com...

>                 for (int j=0; j < AUsers->Count; j++)
>                         {
>                         if (AChannel->Names->Objects[j] == (TObject*) 1)

You are looping through AUsers but then are accessing AChannel->Names
instead.  Try this instead:

    TTeListBox *myListBox = FindListBox(AChannel->Name);
    if( myListBox )
    {
        myListBox->Clear();
        for(int j = 0; j < AChannel->Names->Count; ++j)
        {
            switch( (int) AChannel->Names->Objects[j] )
            {
                case 1:
                    myListBox->Items->Add("@" +
AChannel->Names->Strings[j]);
                    break;
                case 2:
                    myListBox->Items->Add("+" +
AChannel->Names->Strings[j]);
                    break;
                case 3:
                    myListBox->Items->Add("@" + AChannel->Names->Strings[j]
+ "+");
                    break;
                default:
                    myListBox->Items->Add(AChannel->Names->Strings[j]);
                    break;
            }
        }


Gambit
Re: TIdIRC's OnNames
#5404
Author: Tog
Date: Fri, 03 Sep 2004 03:36
5 lines
997 bytes
Thanks Remy,

can't believe I missed that.

Better get some sleep.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads