Blitz Basic question?

Started by
4 comments, last by Narcis 18 years ago
I am trying to make a small little password and username verification program and well it works for numbers but it doesnt for words can someone help me? Here is the code: .loopbegin Username = Input$("Username: ") Password = Input$("Password: ") If Username = 123 And Password= 123 Then Print "Welcome" Else Print "Wrong Password and Username try agean" Delay 2000 Goto loopbegin EndIf WaitKey ______ What is suppose to happen is that if the password and username is right then it will display the text Welcome if rong it will display the text Wrong Password and username try agean and then go back to the log in text. Like i said this will only work for numbers can someone please help me?
Advertisement
I'm not sure how variables and data types work in Blitz, but I'm assuming its like PHP (whatever its called when you don't need to specify data type).

If that's how it works, then you'll need quotes '"' before and after the string you want it to match.

If Username = 123 And Password= 123 ThenPrint "Welcome"


Should be

If Username = "usernamehere" And Password = "passwordhere" ThenPrint "Welcome"
That is what my dad said to do and i get a differnt effect instead of no matter what you put in for username and password it printing "welcome" it will print "Wrong Password and Username try agean" for any username and password. But i have just dound that it will work currectly with a Username of Words and a password of numbers.
I'm not sure about blitz basic, but in most languages the comparison operator for equals is "==" not "=". That could cause problems as well.

So in addition to the poster above it should probably look like :

If Username == "usernamehere" And Password == "passwordhere" ThenPrint "Welcome"

Quote:Original post by EricmBrown
I'm not sure about blitz basic, but in most languages the comparison operator for equals is "==" not "=". That could cause problems as well.

So in addition to the poster above it should probably look like :

If Username == "usernamehere" And Password == "passwordhere" ThenPrint "Welcome"


That isn't the case in any BASIC flavor I've used... The quotes should be required, though.
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute
Goto loopbegin ;Call the sub..loopbegin  Username$ = Input("Username: ")  Password$ = Input("Password: ")  If Username$ = "123" And Password$ = "123" Then  Print "Welcome"  Else  Print "Wrong Password and Username try agean"  Delay 2000  Goto loopbegin  EndIfReturn ;To return the subWaitKey 


In BB you need to show data types. $ = string, # = float, % = int. Also, end the sub... its been a while since I used BB but I still got it in me.

[Edited by - Narcis on April 4, 2006 1:13:46 AM]

This topic is closed to new replies.

Advertisement