• Welcome to Valhalla Legends Archive.
 

Right(message) problem

Started by GoSu_KaOs, November 08, 2004, 04:35 PM

Previous topic - Next topic

GoSu_KaOs

This is my info command. It works like this. When a user types in " .info <username> " , the bot opens the file that has the same name as the user's message with out the .info text .( If I type in " .info GoSu ", then the bot will open the file called "GoSu.txt"), then send the information in the file to bnet. The problem is, I can't get rid of the " .info " text from the message. When I type in ".info GoSu", it will open the file "GoSu.txt". But when I type in something like " .info GoSuKaOs ", the message showes up as "ukaos". If I change the number in " Right((LCase(message)), 5) " to something like 20, the message will show  " .info GoSuKaOs". I Don't get how to make this work.

Here's the code I got:

If username = "GoSu" then
  If Left((LCase(message)), 5) = (Loadtrigger & "info") Then

      Open (App.Path & Right((LCase(message)), 5) & ".txt") For Input As #1
     
      Input #1, za
       
       Send "This user was last seen on: " & za
     
      Close #1
 
  End If
End If


I've explained it as clear as I could. Let me know if you can help

Zakath

Couldn't Mid be used to do this?
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

Yegg

The proper way in doing that would be:

If username = "GoSu" then
  If LCase(Left(message, 5)) = (Loadtrigger & "info") Then

      Open (App.Path & Right(message, (Len(message) - 6)) & ".txt") For Input As #1
     
      Input #1, za
       
       Send "This user was last seen on: " & za
     
      Close #1
 
  End If
End If


.....nice job zakath, u coulda given him an example.

Yoni

#3
Mid(somestring, n) gives the same result (maybe even faster) as Right(somestring, Len(somestring) - n + 1).

And it is not a complicated problem - GoSu_KaOs could have looked up Mid in the VB reference, following Zakath's post, and figured it out.

Edit: Btw, this should be in the VB forum, it's only remotely to do with bot development.

Yegg

but wut if the gosu didn't fully understand Mid? giving an example is a good way in helping some1 understand how to do something the right way.

Zakath

And it also can do the exact opposite. I much prefer giving people pointers to where they can learn to improve their coding technique on their own, rather than simply handing them code that does what they want.
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

Yegg

good point. i jus figured since it looks like hes new to programming from reading his other posts i'd giv him an example.

Zakath

It really doesn't take a supergenius to understand the entries for Mid in MSDN.
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

Minux

Shouldn't this be in the Visual Basic Forum?