grrr plz help myarray problem

Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)

Moderator: Moderators

Locked
TMM
Posts: 47
Joined: 2003-01-03 19:50
Location: leeds UK
Contact:

grrr plz help myarray problem

Post by TMM » 2003-02-20 20:02

hi i use myarray or trying to for my commands
but its messed up see this command works,

If CurUser.sName = CStr(owner) Then
If Mid(sCurData, 1, 5 + Len(botname)) = "$To: " & botname Then
MyArray = GetCmdArray(sCurData, ">", ";")
Select Case MyArray(0)


Case "DEMOTE"
If UBound(MyArray, 1) = 1 Then
If demote(MyArray(1)) Then
Curuser.PrivateMessage CStr(botname), MyArray(1) & " is deleted"
Else
Curuser.PrivateMessage CStr(botname), MyArray(1) & " is not a power OP"
End If
Else
Curuser.PrivateMessage CStr(botname), "error may be wrote wrong try - demote;nick"
End If
End Select
End If
End If


but this one dont

If Curuser.bOperator Then
If Mid(sCurData, 1, 1) = "$" Then
privat = 1
End If
MyArray = GetCmdArray(sCurData, ">", ";")
Select Case MyArray(0)

Case "UINFO"
If UBound(MyArray, 1) = 1 Then
Curuser.PrivateMessage CStr(botname), vbCrLf & GetUserInfo(MyArray(1), 1)
Else
Curuser.PrivateMessage CStr(botname), "ERROR::, UINFO;Nick please type again"
End If
End Select
End If

on justintime debugging i get this arror

Microsoft VBScript runtime error: Subscript out of range: '[number: 0]'

and breaks at this line of code
MyArray(1) = UCase(MyArray(0))

strange thing is
demote works like a charm

any idea's

thanks
ashes to ashes, dust to dust, if the dope dont get you. The acid must

Da8add1e
Posts: 30
Joined: 2003-02-04 13:17
Location: Saddams Bunker :)

Post by Da8add1e » 2003-02-21 10:49

OK, lets see that in a more readable format:

Code: Select all

If CurUser.sName = CStr(owner) Then 
   If Mid(sCurData, 1, 5 + Len(botname)) = "$To: " & botname Then 
      MyArray = GetCmdArray(sCurData, ">", ";") 
      Select Case MyArray(0)

      Case "DEMOTE" 
         If UBound(MyArray, 1) = 1 Then 
            If demote(MyArray(1)) Then 
               Curuser.PrivateMessage CStr(botname), MyArray(1) & " is deleted" 
            Else 
               Curuser.PrivateMessage CStr(botname), MyArray(1) & " is not a power OP" 
            End If 
         Else 
            Curuser.PrivateMessage CStr(botname), "error may be wrote wrong try - demote;nick" 
         End If 
      End Select 
   End If 
End If
hmm, well apart from the fact that you use UBound(MyArray, 1) uneccesarily (you only have one dimension so UBound(MyArray) would be fine) i can't see much wrong here, next

Code: Select all

If Curuser.bOperator Then 
   If Mid(sCurData, 1, 1) = "$" Then 
      privat = 1 
   End If 
   MyArray = GetCmdArray(sCurData, ">", ";") 
   Select Case MyArray(0) 

   Case "UINFO" 
      If UBound(MyArray, 1) = 1 Then 
         Curuser.PrivateMessage CStr(botname), vbCrLf & GetUserInfo(MyArray(1), 1) 
      Else 
         Curuser.PrivateMessage CStr(botname), "ERROR::, UINFO;Nick please type again" 
      End If 
   End Select 
End If 
try CStr(MyArray(1), 1) if its as i assume a text string of a user name that is required here, you may then also want to do

Code: Select all

If ItemByName.(CStr(MyArrary(1))) <> Null ' note: Null is a reserved keyword
but all i can think of atm

Note: the code snippets given here are 100% untested and may contain syntax errors
Need NOT Greed (don't abuse poor countries)
Pay the Poor (increase minimum wage)
Tax the Rich (100% SuperTax rate)
(Do ya think thats maybe a little left-wing?)

TMM
Posts: 47
Joined: 2003-01-03 19:50
Location: leeds UK
Contact:

Post by TMM » 2003-02-21 20:39

thanx for reply but yes i did need my array 1 cos i dont want it to take the command demote as the array
also i needed uinfo then name the name info is wanted for will be array 1

anyway what it was is

when a op logged in it ran the code....
the error was no one had said anythoing so array was empty

to solve i just did an if before the if cursuser.boperator

like if If Mid(sCurData, 1, 5 + Len(botname)) = "$To: " & botname Then
so it dident do anything till someone did the command to the bot

but fanx
ashes to ashes, dust to dust, if the dope dont get you. The acid must

Da8add1e
Posts: 30
Joined: 2003-02-04 13:17
Location: Saddams Bunker :)

Post by Da8add1e » 2003-02-22 07:04

i was refering to

Code: Select all

If UBound(MyArray, 1) = 1 Then 
as UBound gives upper bounds of the array and the optional dimension .. , 1) in you case is only really required if you have a two demensional array eg. MyArray(2, 3) not sure what you are refering to but if its now working now thats all you need i guess :)
Need NOT Greed (don't abuse poor countries)
Pay the Poor (increase minimum wage)
Tax the Rich (100% SuperTax rate)
(Do ya think thats maybe a little left-wing?)

Locked