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

if ... then issue (cant recognize 'then')

Started by Tarado, 19 December 2013 - 09:22 AM
Tarado #1
Posted 19 December 2013 - 10:22 AM
Hey

Im trying to code a basic Manual Database on a computer and I was trying to incorporate a search system.
This is the code:
Spoiler
– Search function
function searchName()
write("Search Name")
local input = read("*")
if local = name then – name is a global variable
displayEntry(name) – a seperate function
end
end

It then gives the error:
Spoilerbios:337: [string "DBStorage"]:7: 'then' expected
I know that this means it is expecting a then in line 7.

But as you have seen I HAVE put a 'then' in line 7 so …
Whats going on and what should I do ?

Please respond quickly
Tarado :D/>
Lyqyd #2
Posted 19 December 2013 - 10:37 AM
Have you read the "Read This Post Before Asking Questions" sticky post? This error and its solution are covered in the Common Errors section.

Side note: you'd want to compare input, not local.
Tarado #3
Posted 19 December 2013 - 11:07 AM
ok thanks
minecraftspare #4
Posted 19 December 2013 - 03:50 PM
you need to use a double == for comparison in alot of interpreted languages lua is no exception lyqyd is right check the common errors