Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: WiLD on April 07, 2003, 01:39 AM

Title: [VB] what is it....
Post by: WiLD on April 07, 2003, 01:39 AM
ok im going good on C++ now but i need help on VB  :-\
ok i got a script, i used the search feature to find it but where would i paste it.
would i paste it in the main form source?

heres the script:
if Instr(textline, " ") > 1 Then
 cmd = Split(textline, " ")(0)
 arg1 = Split(textline, " ")(1)
end if


or would i add it in a module?
Title: Re:[VB] what is it....
Post by: Banana fanna fo fanna on April 07, 2003, 12:14 PM
What the fuck? Explain please.
Title: Re:[VB] what is it....
Post by: PaiD on April 07, 2003, 01:44 PM
What r you trying to do?
Title: Re:[VB] what is it....
Post by: Grok on April 07, 2003, 04:15 PM
if Instr(textline, " ") > 1 Then
 cmd = Split(textline, " ")(0)
 arg1 = Split(textline, " ")(1)
end if


Hey I recognize that snippet.  I pasted that as a response to a previous question about how to parse a trigger and its operands.  You should use it in the section of code where you interpret a complete line of channel speech.

Pretending your trigger marker is "/", you might have something like...


   Select Case True
   Case Left(textline, 1) = "/"     'found a trigger .. parse and see which one.
       if Instr(textline, " ") > 1 Then
           cmd = Split(textline, " ")(0)
           arg1 = Split(textline, " ")(1)
           Select Case True
           Case strComp(cmd,"ban")=0            'user wants someone banned
               'handle ban request here..
           Case strComp(cmd,"kick")=0            'user wants someone kicked
               'handle kick request here
           Case strComp(cmd,"say")=0            'you get the point
           Case strComp(cmd,"des")=0
           Case strComp(cmd,"reconnect")=0
           End Select
       end if
   Case Else
       'isn't a trigger request .. evaluate it in other ways...
   End Select


Got it?
Title: Re:[VB] what is it....
Post by: Camel on April 07, 2003, 08:54 PM
heh, i've not seen anybody use a vb "select case true" in a long time...seems to be more of a perl/php thing
Title: Re:[VB] what is it....
Post by: Grok on April 08, 2003, 06:37 AM
There are two ways in which select case true/false is useful.  When you want to pretty-up a big if-elseif-else-endif is one.  The other is to perform an AND or an OR conditional on multiple inputs.
Title: Re:[VB] what is it....
Post by: c0ol on April 10, 2003, 12:07 AM
perl would use an if elsif else statement.  and why split the string 2 times? cant you ( i know 0% VB ) do like (cmd, args) = split(text,' ', 1) where args is a string array and cmd is a string.
Title: Re:[VB] what is it....
Post by: Mesiah / haiseM on April 10, 2003, 11:45 PM
yup.
Title: Re:[VB] what is it....
Post by: Camel on April 11, 2003, 02:58 PM
Quote from: c0ol on April 10, 2003, 12:07 AM
perl would use an if elsif else statement.  and why split the string 2 times? cant you ( i know 0% VB ) do like (cmd, args) = split(text,' ', 1) where args is a string array and cmd is a string.
that's the one thing i miss about perl
you can't grab them both in one line of code, but you don't need to call split twice:
Dim splitCmd() as String
splitCmd = Split(textline, " ", 2)
cmd = splitCmd(0)
arg = splitCmd(1)