NIN3, on 04 September 2012 - 02:49 AM, said:
Rangemuldee, on 04 September 2012 - 02:30 AM, said:
I am trying to write a calculator code and I am making the addition portion of the code, and I keep getting this error.
bios:206: [string "calc"]:13: unexpected symbol
Which is weird considering on line 13 of my "calc" code there are no unexpected symbols (as far as I know), this is my code.
operation = nil
variable1 = nil
variable2 = nil
print("What operation would you like to use?")
operation = io.read()
print("What is the first number in which to use?")
variable1 = io.read()
print("The second number?")
print("Processing...")
tonumber(variable1)
tonumber(variable2)
if "..operation.." == "addition" then
"..variable1.." + "..variable2.."
end
I think you need to cut some of the ".." stuff. so
if operation == addition then
variable1 + variable2
end
I could be wrong, and what I would do instead for that is
if operation==addition then
answer=variable1 + variable2
end
print(anwser)
also, it never collects the second number....
EDIT:fixed spelling in last one...
So I turned this
operation = nil
variable1 = nil
variable2 = nil
print("What operation would you like to use?")
operation = io.read()
print("What is the first number in which to use?")
variable1 = io.read()
print("The second number?")
print("Processing...")
tonumber(variable1)
tonumber(variable2)
if "..operation.." == "addition" then
"..variable1.." + "..variable2.."
end
Into this based upon what you said
operation = nil
variable1 = nil
variable2 = nil
answer = nil
print("What operation would you like to use?")
operation = io.read()
print("What is the first number in which to use?")
variable1 = io.read()
print("The second number?")
print("Processing...")
tonumber(variable1)
tonumber(variable2)
if operation == "addition" then
variable1 + variable2 = answer
end
and I got this
bios:206: [string "calc"]:14: '=' expected
So I thought about adding another '=' so it said '==' but I got the same error