Valhalla Legends Forums Archive | Battle.net Bot Development | [VB] what is it....

AuthorMessageTime
WiLD
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:
[code]if Instr(textline, " ") > 1 Then
cmd = Split(textline, " ")(0)
arg1 = Split(textline, " ")(1)
end if[/code]

or would i add it in a module?
April 7, 2003, 6:39 AM
St0rm.iD
What the fuck? Explain please.
April 7, 2003, 5:14 PM
PaiD
What r you trying to do?
April 7, 2003, 6:44 PM
Grok
[code]if Instr(textline, " ") > 1 Then
cmd = Split(textline, " ")(0)
arg1 = Split(textline, " ")(1)
end if[/code]

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...

[code]
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
[/code]

Got it?[code][/code]
April 7, 2003, 9:15 PM
Camel
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
April 8, 2003, 1:54 AM
Grok
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.
April 8, 2003, 11:37 AM
c0ol
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.
April 10, 2003, 5:07 AM
MesiaH
yup.
April 11, 2003, 4:45 AM
Camel
[quote author=c0ol link=board=17;threadid=977;start=0#msg7440 date=1049951249]
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.
[/quote]
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:
[code]Dim splitCmd() as String
splitCmd = Split(textline, " ", 2)
cmd = splitCmd(0)
arg = splitCmd(1)
[/code]
April 11, 2003, 7:58 PM

Search