Posted 25 July 2012 - 04:03 PM
Hi I have a piece of code that runs a menu to create a password. I run it and get at line 28 "bios:206 ')' expected" Can anyone help me?
CODE:
CODE:
os.loadAPI("/LNEX/APIS/WAPI")
function os.pullEvent()
local cEvent, p1, p2, p3, p4, p5 = os.pullEventRaw()
if cEvent == "terminate" then
end
return cEvent, p1, p2, p3, p4, p5
end
function getCenterX(sText)
local nWidth = term.getSize()
local x = math.floor(nWidth / 2) - math.floor(string.len(sText) / 2)
return x
end
function getCenterY()
local nWidth, nHeight = term.getSize()
local y = math.floor(nHeight / 2)
return y
end
function getRight(sText)
local nWidth = term.getSize()
local x = nWidth - string.len(sText)
return x + 1
end
function runMenu(mChoices, sMenu)
local nSelection = 0
local bLoop = true
while bLoop do
term.clear()
term.setCursorPos(1, 1)
print(sMenuTitle)
print()
for nLine = 0, #mChoices do
local sLine = " "
if nSelection == nLine then
sLine = "> "
end
sLine = sLine .. mChoices[nLine]
print(sLine)
end
local nWidth, nHeight = term.getSize()
local y = nHeight
local x = getRight("LNET Technologies")
term.setCursorPos(x, y)
term.write("LNET Technologies")
local sEvent, nKey = os.pullEvent("key")
if nKey == 200 then
if mChoices[nSelection - 2] then
nSelection = nSelection - 2
end
elseif nKey == 208 then
if mChoices[nSelection + 2] then
nSelection = nSelection + 2
end
elseif nKey == 28 then
if mChoices[nSelection] then
bLoop = false
return nSelection
end
end
end
end
function menu()
repeat
if nMenuNum == 0 then
mChoices = {}
mActions = {}
mChoices[0] = "Login"
mChoices[1] = " "
if not fs.exists("/LNEX/data/retrieve/passuid") then
mChoices[2] = "Create Account"
mChoices[3] = " "
mChoices[4] = "Shutdown"
mChoices[5] = " "
mChoices[6] = "Reboot"
mActions[0] = function()
bMenuLoop = false
shell.run("/LNEX/Client/LNEX")
end
mActions[2] = function() nMenuNum = 1 end
end
mActions[4] = function()
term.clear()
os.shutdown()
end
mActions[6] = function()
term.clear()
os.reboot()
end
local nSelection = runMenu(mChoices, "LNEX Security Preface")
mActions[nSelection]()
else
mChoices[2] = "Shutdown"
mChoices[3] = " "
mChoices[4] = "Reboot"
mActions[0] = function() shell.run("/LNEX/Client/LNEX") end
mActions[2] = function()
term.clear()
os.shutdown()
end
mActions[4] = function()
term.clear()
os.reboot()
end
local nSelection = runMenu(mChoices, "LNEX Security Preface")
mActions[nSelection]()
end
elseif nMenuNum == 1 then
local bChoice = WAPI.runChoiceMenu("Create permanent account?")
if bChoice == true then
term.clear()
repeat
sNewPasscode = WAPI.runInputMenu("Please enter desired passcode:", true, true)
until sNewPasscode ~= ""
WFCI.fWrite("/LNEX/data/retrieve/passuid", sNewPasscode)
WAPI.slowPrint("Passcode set!")
nMenuNum
else
nMenuNum = 0
end
end
until bMenuLoop == false
end
menu()