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

Looking for help with an error i get with my program

Started by exmental, 07 January 2013 - 12:10 AM
exmental #1
Posted 07 January 2013 - 01:10 AM
So i made a misc peripherals program to read my redstone energy cell but i get an error i have tryed to find what it is but im not too good with this kind of stuff.


Here is the program:

m = peripheral.wrap("front")
data = m.get()

for i, j in pairs(data) do
print()tostring(i)..": ".. tostring(j)
end


Here is the error:


bios:338: [String "reader"]:5:
unexpected symbol

woud be greatly appreciated if someone could tell me what the problem is or even write it out for me so can see what error i made Thanks exmental.
Doyle3694 #2
Posted 07 January 2013 - 01:43 AM
Read the error code and it will be pretty obvious. You are missing a ')' at the end of line 5(Who would've guessed it right?)
exmental #3
Posted 07 January 2013 - 01:45 AM
i have added that but now it says unexpected symbol and calm down im new at this first time doing it :D/>
Doyle3694 #4
Posted 07 January 2013 - 01:47 AM
Can you post error code and updated code? :)/>
exmental #5
Posted 07 January 2013 - 01:49 AM
ok if you look at original post i updated it :D/>
Doyle3694 #6
Posted 07 January 2013 - 02:06 AM
the ) should be at the end of the line, not exactly after the (
remiX #7
Posted 07 January 2013 - 02:28 AM
You're using print() function wrong.
yours:
print()tostring(i)..": ".. tostring(j)

proper way:

print(tostring(i) .. ": " .. tostring(j))
Edited on 07 January 2013 - 01:29 AM
ChunLing #8
Posted 07 January 2013 - 10:19 PM
To be precise, you aren't using it wrong so much as not using it at all. Consider:
print() --doesn't print anything
tostring(i)..": ".. tostring(j) --would cause an "expected =" or something like that
Of course, what is happening instead is probably a result of not having a space between print() and tostring(i), confusing the interpreter. But the purpose of the parentheses in a function call is not just to indicate that the function is being called, but to contain the argument list of the function. In the case, of print, anything you want printed has to be in the argument list.