This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
zyphloyd's profile picture

Error - Login Program Hiccup

Started by zyphloyd, 25 July 2012 - 10:05 AM
zyphloyd #1
Posted 25 July 2012 - 12:05 PM
Making a login program with a built in number of tries (3) until it reboots the system.
Not quite a finished product, mainly because of this error.
I would take any suggestions on improving anything that's there.

When I go to run the program(both through start-up[Part of the start-up program] & manual).
I get this error message.

bios:206: [string "login"]:14: '=' expected

Not sure how to fix the error because I'm not sure what it is talking about.


os.pullEvent = os.pullEventRaw

--Intialization --
do
   tries = 1
   triesmax = 3
end

-- Main Loop --

while true do
if tries > triesmax then
os.reboot
else
if tries < triesmax then
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Zyph Computer Security V:1.0")
textutils.slowPrint("========================")
print(" ")
sleep(0.75)
print("UserName: ")
sleep(1.125)
term.setCursorPos(11,4)
textutils.slowPrint("Zyphloyd")
sleep(0.75)
write("Password: ")
sleep(0.75)
function pass()
t = io.read()
if t == "Space101" then
print ("Access Granted.")
sleep(1)
Term.setCursorPos(1,1)
term.clear()
shell.run("hello")
sleep(1.5)
term clear()
term.setCursorPos(1,1)
print(" ")
print("Incorrect Login information.")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("Zyph Computer Security V:1.0")
print("========================")
print(" ")
print("Username: Zyphloyd")
write("Password: ")
pass()
end
end
pass()

Any help or suggestions would be much appreciated.
Thank you.


—–
Improved Code:

http://pastebin.com/wdkHjkA2
OmegaVest #2
Posted 25 July 2012 - 03:33 PM
Reboot is a function, which requires () at its end. That causes the else to throw an error, and the error-handling for some reason does not quite pinpoint that kind of syntactical error.

So, line thirteen should be

os.reboot()
tfoote #3
Posted 25 July 2012 - 05:53 PM
suggestion if you really want to go technical and all that… make a computer your user server. make it so that when they enter a username that it cecks with a server. I found it to be very helpfull with learning about tables, rednet and all sorts of stuff. also… it removes the possibility of hackers… (only part)
zyphloyd #4
Posted 26 July 2012 - 01:49 AM
Thank you very much, can't believe that i missedthat :)/>/>.

That server idea is a good one, might start looking into rednet a bit.

—–
Fixed a few more errors, I think its about done. Thanks for the help and suggestions guys.
zyphloyd #5
Posted 27 July 2012 - 06:29 AM
Still having a few issues in finalizing this program.

Error: bios:206: [string "login"]:48: '<eof>' expected.

Now I now '<eof>' is something about needing to end a group, an If statement in my case I believe, but not sure how.

Code:http://pastebin.com/wdkHjkA2

os.pullEvent = os.pullEventRaw
-- Initialization --
do
tries = 1
triesmax = 3
version = 2.5
win = false
end
-- Main Loop --
while true do
if tries > triesmax then
  break
else
  textutils.slowPrint("Zyph Computer Security V:2.5")
  textutils.slowPrint("============================")
  print(" ")
   sleep(0.75)
  print("Username: ")
   sleep(1.125)
  term.setCursorPos(11,4)
  textutils.slowPrint("Zyphloyd")
   sleep(0.75)
  write("Password: ")
   sleep(0.75)
  t = io.read()
   if t == "Star101" then
    win = true
    break
   else
    print(" ")
    print("Incorrect Login Information")
	 sleep(1)
    term.clear()
    term.setCursorPos(1,1)
    print("Zyph Computer Security V:2.5")
    print("============================")
    print(" ")
    print("Username: Zyphloyd")
    print("Password: ")
   end
   tries = tries + 1
  end
end
end
-- Outro --
do
if win == true then
  print ("Access Granted.")
   sleep(1)
  term.setCursorPos(1,1)
  term.clear()
   shell.run ("hello")
    sleep(1.5)
   term.clear()
   term.setCursorPos(1,1)
  else
   os.reboot()
  end
end
end
Lyqyd #6
Posted 27 July 2012 - 06:44 AM
<eof> refers to the end of file marker, meaning you've closed every block and then it encounters an end that doesn't belong, rather than the end of the file like it's expecting. I commented out the unnecessary bits of code:


os.pullEvent = os.pullEventRaw
-- Initialization --
--do
tries = 1
triesmax = 3
version = 2.5
win = false
--end
-- Main Loop --
while true do
    if tries > triesmax then
        break
    else
        textutils.slowPrint("Zyph Computer Security V:2.5")
        textutils.slowPrint("============================")
        print(" ")
        sleep(0.75)
        print("Username: ")
        sleep(1.125)
        term.setCursorPos(11,4)
        textutils.slowPrint("Zyphloyd")
        sleep(0.75)
        write("Password: ")
        sleep(0.75)
        t = io.read()
        if t == "Star101" then
            win = true
            break
        else
            print(" ")
            print("Incorrect Login Information")
            sleep(1)
            term.clear()
            term.setCursorPos(1,1)
            print("Zyph Computer Security V:2.5")
            print("============================")
            print(" ")
            print("Username: Zyphloyd")
            print("Password: ")
        end
        tries = tries + 1
    end
end
--end
-- Outro --
--do
if win == true then
    print ("Access Granted.")
    sleep(1)
    term.setCursorPos(1,1)
    term.clear()
    shell.run ("hello")
    sleep(1.5)
    term.clear()
    term.setCursorPos(1,1)
else
    os.reboot()
end
--end
--end
zyphloyd #7
Posted 27 July 2012 - 07:16 AM
Oh, Thanks, that makes more sense.
zyphloyd #8
Posted 27 July 2012 - 07:54 AM
Thank you all very much for your help.

I think I have it working the way I want.

I appreciate the help a lot. :D/>/>

(Now to look into rednet :)/>/> )