Sign in to follow this  
Lumpyspud

Blitz Basic question?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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 Then
Print "Welcome"


Should be


If Username = "usernamehere" And Password = "passwordhere" Then
Print "Welcome"

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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" Then
Print "Welcome"

Share this post


Link to post
Share on other sites
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" Then
Print "Welcome"


That isn't the case in any BASIC flavor I've used... The quotes should be required, though.

Share this post


Link to post
Share on other sites

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
EndIf
Return ;To return the sub
WaitKey


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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this