Loop error

Started by
5 comments, last by K_J_M 15 years, 10 months ago

username$ = Input$( "To Log in Type your username:")
password = Input( "Please type in your password:")

;Function performed if access is granted		
Function yes(username$,password)

Print "Welcome back " + username$ + "!" 
	Delay 2000

Print "Hit any key to continue."
	WaitKey
		End Function

;functio nperformed if access is denied
Function no(username$,password)

Print "Your username or password is incorrect."
	Delay 2000
	
Print "Please try again."
	WaitMouse
		End Function

Repeat ;*Beginning of loop* Keeps asking for correct authorization
	
	If username$ <> "Colin" Or password <> 11032 Then
		no(username$,password)

Until  ;When access is granted it will end the program

	Else
		yes(username$,password)
EndIf

End 

For some reason it gives me the error message that I have "Until" without "Repeat". Any clues as to why this is a busted code? [Edited by - Colin333 on June 16, 2008 10:46:01 PM]
Advertisement
What language is this? Can you paste the EXACT error message you get?

If I had to give a blind guess, I'd gesture that this language asks you to write until expression, repeat {}.

Still, without recognizing the language, I couldn't even research the solution.
Its the way you've scoped it out

put Until after Endif
I don't know which language this is either, but this doesn't look right:

Repeat ;*Beginning of loop* Keeps asking for correct authorization		If username$ <> "Colin" Or password <> 11032 Then		no(username$,password)Until  ;When access is granted it will end the program	Else		yes(username$,password)EndIfEnd



I think what you intended was:

Repeat     If <condition>           ;do stuff     Else           ;do other stuff     EndIfUntil


Even so, I don't think you'll get the results you expect.

I don't see anything indicating that the user will be able to "try again" after entering input for the name and the password once.

Furthermore, it took me a lot longer than it should have to review your code, please make better use of whitespace and tabing.
while username$ <> "colin" and password <> 11032

if keydown(KEY_ESCAPE) = true then end

username$ = Input$( "To Log in Type your username:")
password = Input( "Please type in your password:")

wend


print "Succesful Authentification"
print "programme keeps running "

end



KJM
oh sorry! It's written in BASIC, not C++, sorry for not mentioning that earlier.

Repeat ;*Beginning of loop* Keeps asking for correct authorization		If username$ <> "Colin" Or password <> 11032 Then		no(username$,password)Until  ;When access is granted it will end the program	Else		yes(username$,password)/The program should ask the user for their username or password until the input is correct. But all I get when I try to run it is an error message claiming "Until" without "Repeat". *Please note that I'm running this code through the ancient blitzbasic.



In my code the I wanted a loop that would keep asking user for his/her
username/password until the user typed it in correctly. That's why I used the
repeat...until loop. And that's what I'm trying to achieve with this loop.

Quote:Original post by MichaelJackson
Its the way you've scoped it out

put Until after Endif

Already tried that and it tells me "Expecting Expression"

**I'd like everyone to note that I'm using the ancient blitzbasic to run my code. Very old version of the much newer BlitzMax, but still works great
The code i posted above is blitz basic code.

And should work perfectly for you.

Use a while wend loop instead of repeat until.


KJM

This topic is closed to new replies.

Advertisement