Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: GoSu_KaOs on November 08, 2004, 04:35 PM

Title: Right(message) problem
Post by: GoSu_KaOs on November 08, 2004, 04:35 PM
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
Title: Re: Right(message) problem
Post by: Zakath on November 08, 2004, 05:01 PM
Couldn't Mid be used to do this?
Title: Re: Right(message) problem
Post by: Yegg on November 08, 2004, 05:35 PM
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.
Title: Re: Right(message) problem
Post by: Yoni on November 08, 2004, 05:49 PM
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.
Title: Re: Right(message) problem
Post by: Yegg on November 08, 2004, 05:50 PM
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.
Title: Re: Right(message) problem
Post by: Zakath on November 08, 2004, 05:58 PM
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.
Title: Re: Right(message) problem
Post by: Yegg on November 08, 2004, 06:01 PM
good point. i jus figured since it looks like hes new to programming from reading his other posts i'd giv him an example.
Title: Re: Right(message) problem
Post by: Zakath on November 08, 2004, 06:14 PM
It really doesn't take a supergenius to understand the entries for Mid in MSDN.
Title: Re: Right(message) problem
Post by: Minux on November 08, 2004, 07:17 PM
Shouldn't this be in the Visual Basic Forum?