4 posts
Location
Poland
Posted 20 August 2015 - 09:58 PM
Hi i'm new in forum and i from poland
Please understand my English because i can't write very well and say
I have one problem with program
Here :
- os.pullEvent = os.pullEventRaw
- login = Fufciak
- Pass = Pisze
- while true do
- term.clear()
- term.setCursorPos(1, 1)
- print("Witaj w systemie FufuOS")
- print("Co chcesz zrobic?")
- print("[1] Zaloguj")
- print("[2] Wylacz komputer")
- write("> ")
- input = read()
- if input == "2" then
- os.shutdown()
- elseif input == "1" then
- print("Prosze sie zalogowac")
- write("Uzytkownik: ")
- Uzytkownik = read()
- write("Haslo: ")
- Haslo = read("*")
- if (Uzytkownik == login) and (Haslo == Pass) then
- print("Zalogowano!")
- break
- elseif
- print("Nieprawidlowe dane!")
- sleep(2)
- os.shutdown()
- end
- end
- end
Any one can correct me program ?
I will be very thankfull
:rolleyes:/>
2427 posts
Location
UK
Posted 20 August 2015 - 10:44 PM
What is the error?
121 posts
Posted 20 August 2015 - 10:46 PM
Its becuase you are not comparing it to a string, try this:
login = "Fufciak"
Pass = "Pisze"
Edited on 20 August 2015 - 08:51 PM
2427 posts
Location
UK
Posted 20 August 2015 - 10:49 PM
Good spot The_Cat, that like was it. Other than some bad practice and a useless while true, I see no other errors.
Edited on 20 August 2015 - 08:49 PM
1220 posts
Location
Earth orbit
Posted 21 August 2015 - 12:14 AM
There's also appears to be an unnecessary 'break' near the end of the code (just before the elseif)
Edited on 21 August 2015 - 12:25 AM
8543 posts
Posted 21 August 2015 - 12:50 AM
That's necessary unless the loop is excised. And the loop should be left in, instead getting rid of the reboot call.
1220 posts
Location
Earth orbit
Posted 21 August 2015 - 02:25 AM
Oh, silly me - I didn't even see the loop - thanks for pointing that out
Edited on 21 August 2015 - 12:30 AM
4 posts
Location
Poland
Posted 21 August 2015 - 05:13 AM
Its becuase you are not comparing it to a string, try this:
login = "Fufciak"
Pass = "Pisze"
I correct that are you write and i have the same error
1220 posts
Location
Earth orbit
Posted 21 August 2015 - 05:29 AM
The elseif around line 24 should just be else
4 posts
Location
Poland
Posted 31 August 2015 - 02:18 PM
Dog the same problem
Anyone can correct finally my try write program ?
1220 posts
Location
Earth orbit
Posted 31 August 2015 - 04:16 PM
Please post the code as it is now so I can see the changes you've made.
797 posts
Posted 31 August 2015 - 05:48 PM
The error you're getting is saying that it's expecting a 'then' after an 'elseif' or 'if' condition. If you have an 'elseif' on its own, followed by a function call, it will assume the function call is part of the condition. Take these as examples:
elseif
f()
a()
elseif f() then
a()
The first one will know that it needs a 'then', but it'll say it needs it after f() because f() is just like a condition (like the second one). That means you'd get the error on line 3 of the first example, for example, because that's the first thing after the condition, which is where the 'then' should be.
Edited on 31 August 2015 - 03:48 PM