This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
digpoe's profile picture

[Error] bios:206: [string "MasterControl"]:15: '<eof>' expected?

Started by digpoe, 19 October 2012 - 03:14 PM
digpoe #1
Posted 19 October 2012 - 05:14 PM
I'm making a small note block song system, and I'm using this lua script to pulse a colored wire a certain number of times to tell another computer what note to play, but on my main control system for it - I have this odd error. Here's the code:

local monitor = peripheral.wrap("left")
term.redirect(monitor)
term.clear()
sleep(5)
local song = {}
local filename = fs.combine(disk.getMountPath("top"), "songdata")
local file = fs.open(filename, "r")
if disk.hasData("top") then
print("Reading song '"..disk.getLabel("top").."' . Commence song!")
for line in io.lines(file) do
table.insert(song, line)
end
end
term.restore()
else
print("No data in disk!")
term.restore()
end
for i = 1, #song do
clin = song[i]
local col
check = string.sub(clin, 1, 2)
if check == "^1" then
col = 1
elseif check == "^2" then
col = 2
elseif check == "^3" then
col = 4
elseif check == "^4" then
col = 8
elseif check == "^5" then
col = 16
end
local nt
notecheck = string.sub(clin, 4)
if notecheck = "1" then
nt = 1
elseif notecheck = "2" then
nt = 2
elseif notecheck = "3" then
nt = 3
elseif notecheck = "4" then
nt = 4
elseif notecheck = "5" then
nt = 5
elseif notecheck = "6" then
nt = 6
elseif notecheck = "7" then
nt = 7
elseif notecheck = "8" then
nt = 8
elseif notecheck = "9" then
nt = 9
elseif notecheck = "10" then
nt = 10
elseif notecheck = "11" then
nt = 11
elseif notecheck = "12" then
nt = 12
elseif notecheck = "13" then
nt = 13
elseif notecheck = "14" then
nt = 14
elseif notecheck = "15" then
nt = 15
elseif notecheck = "16" then
nt = 16
end
print(col.."|"..nt)
local times = nt
repeat rs.setBundledOutput('bottom', col) sleep() rs.setBundledOutput('bottom', 0) times = (times - 1) until times = 0
end
billysback #2
Posted 19 October 2012 - 05:22 PM

local monitor = peripheral.wrap("left")
term.redirect(monitor)
term.clear()
sleep(5)
local song = {}
local filename = fs.combine(disk.getMountPath("top"), "songdata")
local file = fs.open(filename, "r")
if disk.hasData("top") then
    print("Reading song '"..disk.getLabel("top").."' . Commence song!")
	    for line in io.lines(file) do
	    table.insert(song, line)
    end
end
    term.restore()
else << wheres the start?
    print("No data in disk!")
    term.restore()
end
you put in an else with out an if?
also, tab your code, errors like this would be so much easier to spot.
digpoe #3
Posted 19 October 2012 - 05:24 PM

local monitor = peripheral.wrap("left")
term.redirect(monitor)
term.clear()
sleep(5)
local song = {}
local filename = fs.combine(disk.getMountPath("top"), "songdata")
local file = fs.open(filename, "r")
if disk.hasData("top") then
	print("Reading song '"..disk.getLabel("top").."' . Commence song!")
		for line in io.lines(file) do
		   table.insert(song, line)
	   end
end
	term.restore()
else << wheres the start?
	print("No data in disk!")
	term.restore()
end
you put in an else with out an if?
also, tab your code, errors like this would be so much easier to spot.
i see now.. DERP?
Also, around line 35 I missed an extra =
and after that I missed a lot of ='s.
Also, i'm now getting a "attempt to call nil" at 'for line in io.lines(file) do'..
Lyqyd #4
Posted 19 October 2012 - 05:39 PM
Switch your fs.open to an io.open and use file:lines(). io.lines() isn't implemented in CC, but handle:lines() is.
digpoe #5
Posted 19 October 2012 - 05:45 PM
Switch your fs.open to an io.open and use file:lines(). io.lines() isn't implemented in CC, but handle:lines() is.
Ok. I will do that.
digpoe #6
Posted 19 October 2012 - 05:50 PM
Ok, so after all my fixes, the script looks like this:

local monitor = peripheral.wrap("left")
term.redirect(monitor)
term.clear()
sleep(5)
local song = {}
local filename = fs.combine(disk.getMountPath("top"), "songdata")
local file = io.open(filename, "r")
if disk.hasData("top") then
print("Reading song '"..disk.getLabel("top").."' . Commence song!")
for line in file:lines() do
  table.insert(song, line)
end
term.restore()
else
print("No data in disk!")
term.restore()
end
for i = 1, #song do
clin = song[i]
local col
check = string.sub(clin, 1, 2)
if check == "^1" then
  col = 1
elseif check == "^2" then
  col = 2
elseif check == "^3" then
  col = 4
elseif check == "^4" then
  col = 8
elseif check == "^5" then
  col = 16
end
local nt
notecheck = string.sub(clin, 4)
if notecheck == "1" then
  nt = 1
elseif notecheck == "2" then
  nt = 2
elseif notecheck == "3" then
  nt = 3
elseif notecheck == "4" then
  nt = 4
elseif notecheck == "5" then
  nt = 5
elseif notecheck == "6" then
  nt = 6
elseif notecheck == "7" then
  nt = 7
elseif notecheck == "8" then
  nt = 8
elseif notecheck == "9" then
  nt = 9
elseif notecheck == "10" then
  nt = 10
elseif notecheck == "11" then
  nt = 11
elseif notecheck == "12" then
  nt = 12
elseif notecheck == "13" then
  nt = 13
elseif notecheck == "14" then
  nt = 14
elseif notecheck == "15" then
  nt = 15
elseif notecheck == "16" then
  nt = 16
end
print(col.."|"..nt)
local times = nt
repeat
  rs.setBundledOutput('bottom', col)
  sleep()
  rs.setBundledOutput('bottom', 0)
  times = (times - 1)
until times == 0
end
It doesn't like line 68.. (print(col.."|"..nt))
It said: attempt to concatenate string and nil

I fixed that - and now i get an error with this line:
elseif check == "^3" then – bad argument: double expected, got nil
digpoe #7
Posted 19 October 2012 - 06:46 PM
I'm going to guess everyone went offline.. :P/>/>

Can anyone help??
Edited on 19 October 2012 - 05:16 PM
cant_delete_account #8
Posted 19 October 2012 - 07:34 PM
I'm going to guess everyone went offline.. :P/>/>

Can anyone help??
Can you post the newest code? (in a spoiler please)
Lyqyd #9
Posted 19 October 2012 - 07:56 PM
I'm going to guess everyone went offline.. :P/>/>

Can anyone help??

This is a forum, not an instant messaging service. Have some patience, please. You'll need to post the latest version of the code and the full error message. I have the feeling that the error isn't where you're saying it is.
digpoe #10
Posted 19 October 2012 - 08:01 PM
I'm going to guess everyone went offline.. :P/>/>

Can anyone help??

This is a forum, not an instant messaging service. Have some patience, please. You'll need to post the latest version of the code and the full error message. I have the feeling that the error isn't where you're saying it is.

Yeah.. I figured it out. sleep() doesn't like being used with no arguments.
Anyway, here's my updated code.. It's still bugged, as it runs an infinite loop just printing 0|0 to my terminal screen..

local monitor = peripheral.wrap("left")
term.redirect(monitor)
term.clear()
sleep(5)
local song = {}
local filename = fs.combine(disk.getMountPath("top"), "songdata")
local file = io.open(filename, "r")
if disk.hasData("top") then
print("Reading song '"..disk.getLabel("top").."' . Commence song!")
for line in file:lines() do
  table.insert(song, line)
end
else
print("No data in disk!")
term.restore()
end
for i = 1, #song do
clin = song[i]
col = 0
check = string.sub(clin, 1, 2)
if check == "^1" then
  col = 1
elseif check == "^2" then
  col = 2
elseif check == "^3" then
  col = 4
elseif check == "^4" then
  col = 8
elseif check == "^5" then
  col = 16
end
nt = 0
notecheck = string.sub(clin, 4)
if notecheck == "1" then
  nt = 1
elseif notecheck == "2" then
  nt = 2
elseif notecheck == "3" then
  nt = 3
elseif notecheck == "4" then
  nt = 4
elseif notecheck == "5" then
  nt = 5
elseif notecheck == "6" then
  nt = 6
elseif notecheck == "7" then
  nt = 7
elseif notecheck == "8" then
  nt = 8
elseif notecheck == "9" then
  nt = 9
elseif notecheck == "10" then
  nt = 10
elseif notecheck == "11" then
  nt = 11
elseif notecheck == "12" then
  nt = 12
elseif notecheck == "13" then
  nt = 13
elseif notecheck == "14" then
  nt = 14
elseif notecheck == "15" then
  nt = 15
elseif notecheck == "16" then
  nt = 16
end
reptime = nt
repeat
  print(col.."|"..nt)
  rs.setBundledOutput('bottom', col)
  sleep(0.1)
  rs.setBundledOutput('bottom', 0)
  reptime = (reptime - 1)
until reptime == 0
print("Done!")
term.restore()
print("Done!")
end
ChunLing #11
Posted 19 October 2012 - 08:52 PM
[spoiler][code]your code here
Lyqyd #12
Posted 19 October 2012 - 09:53 PM
What are the strings you're feeding it? It looks like they're not formed correctly and so your script is having trouble setting the other variables.
digpoe #13
Posted 20 October 2012 - 12:35 PM
What are the strings you're feeding it? It looks like they're not formed correctly and so your script is having trouble setting the other variables.
What do you mean? Do you mean as in arguments to the program? No i'm not using arguments - i'm reading data from a disk. My test 'song' looks like this:
Spoiler^1-3
^1-2
^1-1
^2-3
^2-2
^2-1
^3-3
^3-2
^3-1
^4-3
^4-2
^4-1
^5-3
^5-2
^5-1
ChunLing #14
Posted 20 October 2012 - 05:47 PM
After line 33, "notecheck = string.sub(clin, 4)", try inserting a "print(notecheck)"

I'm pretty sure the output will help you figure this out.