Valhalla Legends Forums Archive | Battle.net Bot Development | Problem with Array

AuthorMessageTime
inner.
I'm having a problem with finding a user in the array and removing it from the array. What I'm doing is adding the person to the array when they leave, doing a /whois, if they're on, it says they left, if not it says they quit Battle.net, and removing them.

on_leave:
[code]
    If frmMain.mnuJoinleave.Checked = True Then
        If p_Info(Index).strProduct = "PX2D" Or p_Info(Index).strProduct = "VD2D" Then
            Queue "/whois *" & Username
        Else
            Queue "/whois " & Username
        End If
            ReDim Preserve l_name(0 To UBound(l_name) + 1)
            l_name(UBound(l_name) - 1).name = Username
            boolQuit = True
[/code]

on_info:
[code]
        If boolQuit = True Then
            If Message Like "*is using*" Then
                For i = LBound(l_name) To UBound(l_name)
                AddChat Index, vbGreen, l_name(i).name & " has ", AC_BOLD_ON, "left ", AC_BOLD_OFF, "the channel."
                ReDim Preserve l_name(UBound(l_name) - 1)
                Exit Sub
            Next i
        End If
        End If
[/code]

on_error:
[code]
    If boolQuit = True Then
        If Message Like "*is not logged on*" Then
            For i = 0 To UBound(l_name)
            AddChat Index, vbRed, l_name(i).name & " has ", AC_BOLD_ON, "quit ", AC_BOLD_OFF, "Battle.net (Signed off)"
            Next i
            ReDim Preserve l_name(UBound(l_name) - 1)
            Exit Sub
        End If
[/code]

Any help is appreciated. :p
June 4, 2006, 6:23 AM
rabbit
Why are you doing ReDim Preserve l_name(UBound(l_name) - 1) in your loops?
June 4, 2006, 11:39 AM
FrOzeN
Your using my addchat procedure. :)
June 4, 2006, 11:54 AM
inner.
[quote author=rabbit link=topic=15121.msg153791#msg153791 date=1149421158]
Why are you doing ReDim Preserve l_name(UBound(l_name) - 1) in your loops?
[/quote]

So it will remove the last thing added.

Frozen: Yes. I liked it. :p
June 4, 2006, 2:03 PM
rabbit
You shouldn't be assuming things.  Check what it is before you remove it.
June 4, 2006, 2:44 PM
warz
[quote author=rabbit link=topic=15121.msg153794#msg153794 date=1149432260]
You shouldn't be assuming things. Check what it is before you remove it.
[/quote]

This is what I was telling him. He will need to locate the name in the array, find the index of that name and then delete that name. Then, he willl  need to move every name after that name up one spot to fill in the gap. Then he can safely redim the array. Because, whois to say that the person to be removed from the array is the person sitting at the very end of the array?
June 4, 2006, 3:42 PM
UserLoser
[quote author=rabbit link=topic=15121.msg153791#msg153791 date=1149421158]
Why are you doing ReDim Preserve l_name(UBound(l_name) - 1) in your loops?
[/quote]

What I had said
June 4, 2006, 5:27 PM

Search