645 posts
Location
'Merica
Posted 10 March 2013 - 09:35 PM
Well as the title says, I got a Error: bios:338: [string "DynationOS"]:19: '}' expected (to close '{' at line 17)
the weird thing is, is it is closed… can someone help me out by fixing it? Don't worry, I didn't make you guys have to hunt for the section I need help in, the full program is not even close to being finished and already 150 lines.
Spoiler
term.setTextColor(colors.blue)
print("Account name: ")
term.setTextColor(colors.white)
local user =
{
file = fs.open("Account","r")
user = file:readLine()
}
local name = read()
if name == (user) then
file.close()
term.setTextColor(colors.blue)
print("Password: ")
local pass =
{
file = fs.open("Account","r")
pass = file:readLine()
}
term.setTextColor(colors.white)
local passw = read()
elseif passw == (pass) then
file.close()
User()
else
file.close()
term.setTextColor(colors.red)
print("Sorry account does not exist")
sleep(1.5)
print("Redirecting you to setup")
setup()
end
7508 posts
Location
Australia
Posted 10 March 2013 - 09:39 PM
each entry in a table must be separated by a comma. you have not done this. so fix that and you should be good.
EDIT: Well actually idk what you're doing there
is it meant to be this
local handle = fs.open("Account","r")
local user = handle.readLine()
or is it meant to be this
local user = {}
user["file"] = fs.open("Account","r")
user["user"] = user.file.readLine()
997 posts
Location
Wellington, New Zealand
Posted 10 March 2013 - 09:49 PM
It's meant to be this:
local user =
{
file = fs.open("Account","r"),
user = file:readLine()
}
Note the comma.
645 posts
Location
'Merica
Posted 10 March 2013 - 09:50 PM
each entry in a table must be separated by a comma. you have not done this. so fix that and you should be good.
EDIT: Well actually idk what you're doing there
is it meant to be this
local handle = fs.open("Account","r")
local user = handle.readLine()
or is it meant to be this
local user = {}
user["file"] = fs.open("Account","r")
user["user"] = user.file.readLine()
Lol well I didn't want to post the ENTIRE program code, but what that function does it allows you to login… so I was trying to call the users information from one file to the main program.
EDIT: I put the commas in, it didn't give me a error, but it didn't work correctly… I probably need to fix the account file..
7508 posts
Location
Australia
Posted 10 March 2013 - 09:50 PM
It's meant to be this:
local user =
{
file = fs.open("Account","r"),
user = file:readLine()
}
Note the comma.
Could that not cause problems considering you are trying to reference a table element while constructing the second element?
997 posts
Location
Wellington, New Zealand
Posted 10 March 2013 - 09:52 PM
It's meant to be this:
local user =
{
file = fs.open("Account","r"),
user = file:readLine()
}
Note the comma.
Could that not cause problems considering you are trying to reference a table element while constructing the second element?
Oh - yeah, that won't work.
It's also file.readLine not file:readLine
io uses :, fs uses .
And in your code, user["file"] and user["user"] can be replaced by user.file and user.user
7508 posts
Location
Australia
Posted 10 March 2013 - 09:57 PM
And in your code, user["file"] and user["user"] can be replaced by user.file and user.user
I've found it doesn't always work for me, but either way, using . notation is just syntactical sugar, its not functionally any different.
645 posts
Location
'Merica
Posted 10 March 2013 - 10:01 PM
If one of you thinks they can help way more by seeing the entire code PM me, since it still doesn't work as I want it too.