Posted 23 September 2013 - 01:07 AM
I'm writing a code that requires a while true do statement inside a repeat statement. I'm using the while true do to wait for a button press for an option posed on the screen, while the repeat is there to let it repeat with a different option. I want to know if I can get out of the while true statement, but STAY in the repeat statement.
Code:
The forums doesn't like that i use tab to organize my code…
Code:
Spoiler
function Newuserschecklist()
local bob = fs.open("Users/Newuserschecklist","r") -- opens a file that holds new usernames the program registered to accept or deny
local filebob = {}
local tag = bob.readLine()
table.insert(filebob,tag)
z = 2
tag = bob.readLine()
if tag == nil then
print("No new users.")
sleep(2.5)
Adminmenu()
else
repeat
term.clear()
term.setCursorPos(1,1)
table.insert(filebob,tag)
local alpha = filebob[z]
print(alpha)
print("1. Accept")
print("2. Decline")
while true do
local sir, henry = os.pullEvent ("char")
if henry == "1" then
local newbob = fs.open("Users/1"..alpha,"r")
local file = newbob.readLine()
local test = {}
repeat
table.insert(test,file)
file = newbob.readLine()
until file == nil
newbob.close()
local chick = fs.open("Users/1"..alpha,"w")
chick.writeLine(test[1])
chick.writeLine("Newbie")
chick.close()
break -- these are the problems, its not working the way i need and keeps getting out of the loop instead of searching for new users again.
elseif henry == "2" then
local newbob = fs.open("Users/1"..alpha,"r")
local file = newbob.readLine()
local test = {}
repeat
table.insert(test,file)
file = newbob.readLine()
until file == nil
newbob.close()
local chick = fs.open("Users/1"..alpha,"w")
chick.writeLine(test[1])
chick.writeLine("Denied")
chick.close()
break -- read above comment
end
end
z = z + 1
tag = bob.readLine()
until line == nil
bob.close()
local guess = fs.open("Users/Newuserschecklist","w")
guess.writeLine("la")
guess.close()
Bob() -- sends back to my intro function that starts the program
end
end
The forums doesn't like that i use tab to organize my code…