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

Strange error code ( bios: 338: [string "startup"] :15: '=' expected)

Started by pigletx2, 09 July 2013 - 03:44 PM
pigletx2 #1
Posted 09 July 2013 - 05:44 PM
I cant figure out why, but my code thinks line 15 needs an equal sign, which makes no sense based on my code. Also, any random tips are welcomed.


function clear()
   term.clear()
   term.setCursorPos(1, 1) -- creates an ez clear function
end
clear()
local pass = ""
term.write("Enter the password: ")
pass = read()
if pass ~= "PX2" then
   clear()
   print("Wrong Password idiot!")
   sleep(1)
   os.reboot()
else -- the error is occurring here
	  clear()
	  print("Password Correct!")
	  sleep(1)
	  clear()
	  print("CraftOS 1.5, protected by passlock")
end
IMPORTANT EDIT: The code was incorrect on the website, the code is now corrected to be the same as ingame, and still does not work.
Lyqyd #2
Posted 09 July 2013 - 11:25 PM
Split into new topic.

The keyword you're looking for is `else`.
apemanzilla #3
Posted 10 July 2013 - 06:54 AM
I would recommend using ineents properly, it can help clean up code some. Also using a text editor that has syntax highlighting, such as the build in editor on an advanced computer, can help solve errors like these.
albrat #4
Posted 10 July 2013 - 10:44 AM
because you had elce (mis-spelling of else) the interpreter is looking for a value or string to assign to the varible "elce" hence the expected = error.
albrat #5
Posted 10 July 2013 - 10:48 AM
I would recommend using ineents properly, it can help clean up code some. Also using a text editor that has syntax highlighting, such as the build in editor on an advanced computer, can help solve errors like these.

When using the code tags here I have noticed that it drops some of your indents even when it should not…

I use notepad++ its free and has a Lua language pack that highlights correct language and also gives you a handy +/- at the side so you can see where your if then else / end statements work out.
apemanzilla #6
Posted 10 July 2013 - 12:51 PM
I would recommend using ineents properly, it can help clean up code some. Also using a text editor that has syntax highlighting, such as the build in editor on an advanced computer, can help solve errors like these.

When using the code tags here I have noticed that it drops some of your indents even when it should not…

I use notepad++ its free and has a Lua language pack that highlights correct language and also gives you a handy +/- at the side so you can see where your if then else / end statements work out.

That works too, just make sure it highlights keywords.
pigletx2 #7
Posted 10 July 2013 - 04:31 PM
Wow. Spelling fail that i didn't notice, even when I looked at the line. Silly me. Thanks for the help.
EDIT, CONTINUE HELP
The spelling mistake does not occur in my code, only the copied code.
Going to edit the main post now to express said discovery.
Edit 2: and i got one of those syntax-things.
Edit 3: at @ape, I use indents in my code, but they dont work here + I was franticly copying my code over( which caused the elce instead of else.)
Lyqyd #8
Posted 10 July 2013 - 08:05 PM
If you copied it by retyping, you need to slowly go through the code and verify that every single character of every word on every line matches exactly.
apemanzilla #9
Posted 11 July 2013 - 07:30 AM
The best way to copy the code over would be to post it to pastebin (pastebin put <program name>) and then link it or copy it over.

If the posted code is the same as the in game code, it should be working fine.
AgentE382 #10
Posted 11 July 2013 - 07:44 AM
The best way to copy the code over would be to post it to pastebin (pastebin put <program name>) and then link it or copy it over.

If the posted code is the same as the in game code, it should be working fine.
Best way to copy the code is to open the file in your .minecraft and copy-and-paste it into code tags here.

I don't know about anyone else, but I always keep my .minecraft\saves\<world name>\computer\<number> folder open in a file menager when I'm writing programs.

EDIT: Even when I'm using CC-Desk. It's .ccdesk\computer\<number>
Edited on 11 July 2013 - 05:48 AM
apemanzilla #11
Posted 11 July 2013 - 07:51 AM
The best way to copy the code over would be to post it to pastebin (pastebin put <program name>) and then link it or copy it over.

If the posted code is the same as the in game code, it should be working fine.
Best way to copy the code is to open the file in your .minecraft and copy-and-paste it into code tags here.

I don't know about anyone else, but I always keep my .minecraft\saves\<world name>\computer\<number> folder open in a file menager when I'm writing programs.

EDIT: Even when I'm using CC-Desk. It's .ccdesk\computer\<number>
If you play on a server, you don't have access to those folders.
CosmoConsole #12
Posted 11 July 2013 - 10:35 AM
Cannot reproduce any error, if the code is exactly how it's on here.

TIP: If you're creating a password lock, make sure to disable termination with Ctrl+T. ("os.pullEvent = os.pullEventRaw" will do the trick)
apemanzilla #13
Posted 11 July 2013 - 12:57 PM
Tried it and got no errors… Any other code you're running before this? (Including other programs)

Try rebooting the computer and running that exact code, and only that code. If it works, great, otherwise, I'm out of ideas.