Re: Help in a Simple Program
- Posted by DerekParnell (admin) Nov 17, 2011
- 1285 views
Euphoric_Kid said...
When I enter Euphoria as password when program runs it shows Access Denied. But when I change password=password[1..length(password)-2], then it works fine. Why???
There is a bug in Euphoria when it comes to reading console input in a Windows system. The line ending should be a single LF (#0A) character, but in Windows we are getting a CRLF (#0D#0A) combination. Try this instead.
object password, whatever puts(1,"Enter your password: ") password = gets(0) if password[$] = 10 then password = password[1..$-1] end if if password[$] = 13 then password = password[1..$-1] end if if compare(password,"Euphoria")=0 then puts(1,"[Password Authenticated]") else puts(1,"[Incorrect password - Access Denied!]") end if whatever=gets(0)
If you are using Eu4, then a simplier way is ...
include std/text.e object password, whatever puts(1,"Enter your password: ") password = trim(gets(0)) if equal(password,"Euphoria") then puts(1,"[Password Authenticated]") else puts(1,"[Incorrect password - Access Denied!]") end if whatever=gets(0)