Login from?

BlitzPlus Forums/BlitzPlus Programming/Login from?

This is what I have so far:


;my login from
;variables
usernm = 141
passwd = 89511

Goto anew

.bnew
newuser = Input$("What is your perferd user (must be a number)? ")
newpass = Input$("Password (must be a number)? ")
Delay 250
Print "Thank You!"
Print " "
Delay 500
Goto begin

.aNew
k = Input$("Do you have an account (press 1 for yes, 2 for no)? ")

If k = 1 Then
Delay 250
Print "Thank You!"
Print " "
Delay 150
Goto begin

Else If k = 2 Then
Print " "
Delay 500
Delay 150

Goto bnew

Else
Print "what?"
Delay 100
Goto aNew

EndIf 

.begin
user = Input$("User: ")
pass = Input$("Pass: ")

If user = usernm And pass = 89511 Then
Print "Congrats!"
Delay 3500
End 

Else
Print "sorry!"
Print " "
Delay 1000
Goto begin

EndIf




I want the user and pass to come from a file called user.txt
and I also I want if the person presses 2 I want it to take them to a form were they can make an account and then that account gets saved to user.txt.

Bloody hell, I'm not being cheeky, but I've never seen code like that since the 80's!!!

Its a bit of a slug to read, you should make it more readable for our sake, and simplify the execution, for your users sake... ! ;)

;A couple of global variables,just in case
Global userID%,userPassword$

;Start up
StartUp()


Function Startup()
Print "Checking for details"
;Try and open the user file
filein = ReadFile("user.txt")
If filein <> 0
	userID = Int(ReadLine$(filein))
	userPassword = ReadLine$(filein)
	Print "You are authorised..."
	Print "UserID:"+userID
	Delay 3000
Else
	Print "You are a new user, please create an account:-
	Print ""
	userID = Int(Input$("Enter a new user ID Number: "))
	userPassword$ = Input$("Enter a new Password: ")
	;Create a new file
	fileout = WriteFile("user.txt")
	WriteLine(fileout,userID)
	WriteLine(fileout,userPassword)
	CloseFile fileout
	Print ""
	Print "Thank you, you are automatically logged in"
	Delay 3000
End If
CloseFile filein
End Function 


Dabz

Sorry, I am not that good yet :(


Sorry, I am not that good yet :(



No sweat! ;) Just try not to rely on the Goto command as often, as it makes code harder to read, and harder to understand how the program is flowing.

If you browse through the samples, and other peoples work, you'll sharp learn, so keep it up! :D

Dabz

Hummm, I think that whatever book/course you are following is outdated. Its not really a question of not being good enough yet.

Its sort of like using 16th Century English, then saying "Sorry Ive only been learning for a year", youve basicly been learning the wrong English.

Dont get me wrong, you will learn to program following such a course, but you might as well miss the 80's out.

Apart from the gotos, this is all posted in this B+ section, I'd say: use the GUI! A GUI like Windows was made to make exactly these kind of interactions easier to make. Typically all the interaction between human and computers takes up 90% of the whole code time, having a standard GUI instead is a revelation.