Jump to content
  • Advertisement
Sign in to follow this  
Colin333

Loop error

This topic is 3659 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


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

Share this post


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

End




I think what you intended was:

Repeat
If <condition>
;do stuff
Else
;do other stuff
EndIf
Until



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.

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!