Posted 07 June 2017 - 04:45 PM
For the love of my life, I can't find what needs to be done to fix this code. My program is supposed to replicate itself to a disk if a disk is present, and do nothing if there is no disk present. If a disk is present and a startup file exists it will not replicate itself to the disk. I checked for any errors with the presence of "end" statements as there are a lot of them in my code and they are a little messy. I placed a disk drive with an empty floppy disk on the right side of my advanced computer, ran the code inside of the edit program, and I received this error:
Here is my code:
bios:14: [string ".temp"]:20: 'then' expected
I looked at line 20 and there is no missing "then" and I checked according to the "Read This Post Before Asking Questions" thread and I can still not find an error.Here is my code:
print("Initializing...")
os.pullEvent = os.pullEventRaw
-- Just in case you pressed Ctrl T while it's still running because stopping in the middle of this program would confuse me if I ever had to manage the aftermath.
print("Replicating...")
side = {"top","bottom","left","right","up","down","front","back"}
-- For defining the names of sides to a variable then below it checks for a disk NOT containing a startup file
i = nil
for i = 1,#side do
if peripheral.getType(side[i]) == "drive" then
if disk.isPresent(side[i]) then
diskf = fs.list("/disk")
for i = 1,#diskf do
if diskf[i] != "startup" then
startupExists = false
i = i + 1
else
startupExists = true
end
if startupExists == true then
i = #diskf
end
end
fs.copy("/spreader","/disk/startup") -- This is creating a startup file with the contents of this program, "spreader"
end
end
end