Posted 30 April 2014 - 04:51 AM
I'm trying to write a program to run a message from another computer as a command.
I want the program to return "success" if the program was found and run and "failure" if it was not.
With the following structure, however, the program will spam "FAILURE" indefinitely.
I know there has to be some issue there with the end of the loop, but I can't figure it out. Should there be a break in there, or more ends inside the loop? Any help would be appreciated. After it sends the message back to computer 1 I would, of course, like the loop to reset. I know this is a stupid question, but I can't figure it out.
I want the program to return "success" if the program was found and run and "failure" if it was not.
With the following structure, however, the program will spam "FAILURE" indefinitely.
rednet.open("top")
while true do
event, id, text = os.pullEvent()
if event == "rednet_message" and id == 1 then
if fs.exists(text) then
shell.run(text)
rednet.send(1, "SUCCESS")
else rednet.send(1, "FAILURE")
end
end
end
I know there has to be some issue there with the end of the loop, but I can't figure it out. Should there be a break in there, or more ends inside the loop? Any help would be appreciated. After it sends the message back to computer 1 I would, of course, like the loop to reset. I know this is a stupid question, but I can't figure it out.