Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: titan0060 on August 30, 2004, 10:28 AM

Title: [VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: titan0060 on August 30, 2004, 10:28 AM
Ok, im trying to program commands into my bot, but i've only been able to get !ver because it doesn't run a second word.

when i say... !Kick JohnDoe
is there a way i can have my bot pick up the !Kick without the JohnDoe.

Help me out plz

[Kp edit: gave him a new title, then kicked him out of botdev.  His question is about basic text parsing, which belongs in the forum of his language of choice.]
Title: Re:Commands ("kick" , "ban exe)
Post by: Banana fanna fo fanna on August 30, 2004, 10:34 AM
You need to ***LEARN VB!***

And don't say you do, this is a trivial task.

Hint: use Split()
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: Warrior on August 30, 2004, 12:11 PM
I might be able to put together ban.exe :P
Title: Re:Commands ("kick" , "ban exe)
Post by: Grok on August 30, 2004, 02:16 PM
Quote from: $t0rm on August 30, 2004, 10:34 AM
You need to ***LEARN VB!***

And don't say you do, this is a trivial task.

Hint: use Split()

Yes, Split, Join, Choose, and Switch are all excellent useful VB functions for text processing.  Learn them all!
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: Stealth on August 31, 2004, 12:08 AM
Mid$() and InStr() are also essential.
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: Eli_1 on August 31, 2004, 05:30 AM
I use Right() and Left() a lot.
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: Meh on August 31, 2004, 10:18 AM
Lcase = and Rcase =
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: Banana fanna fo fanna on August 31, 2004, 10:19 AM
Ever since discovering regex, I can't go back.
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: Blaze on September 01, 2004, 09:11 PM
Don't forget UCase!
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: l)ragon on September 02, 2004, 11:44 AM
Might want to look up the 'if' statment aswell, since you will probably use that quite often.
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: R.a.B.B.i.T on September 03, 2004, 10:08 PM
And Split() can be helpful sometimes.
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: Forged on September 03, 2004, 11:38 PM
if lcase(message)="!kick" & name then
csb.send = "/kick" &name

Assuming you are using csb and have name defined as a string

(I have no idea what you are asking but this seemed like it)
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: Banana fanna fo fanna on September 04, 2004, 08:42 AM
This regex should do it for you:

%c(\w+?)\s*?(.*?)

And sub in your trigger for %c. Command name will be group 1, args will be group 2.
Title: Re:[VB? - extracting text fields] Commands ("kick" , "ban exe)
Post by: LivedKrad on September 12, 2004, 12:49 AM
[Let us assume that the thread starter was referring to Visual Basic!]


Quote from: Forged on September 03, 2004, 11:38 PM
if lcase(message)="!kick" & name then
csb.send = "/kick" &name

Assuming you are using csb and have name defined as a string

(I have no idea what you are asking but this seemed like it)

So, we would have to look at this assuming the variable "name" is declared as a sectioned part of the message? For instance, if I wanted to extract "Forged" from ".kick Forged", and I set up a control flow statement to extract "name", it's going to give some goofy error. You'll need to have something to the effect of...

Public name as String


If LCase(message) = someTrigVar & "kick " Then
name = mid$(message, 6) 'Extract all text from the 'message' variable starting from position 6; can be reused so long as the variable receives a new value per action
WhateverObject.Send "/kick " & name
End If