Error for print
phaleron 19 Jan 2013
hey guys,
iv'e got an error when i send something from my other computer..
and its showing only when im using "print(hey)"
rednet.open("back")
term.clear()
term.setCursorPos(1,1)
i, m = rednet.receive()
write("van "..i.."")
print("hey")
write(m)
beside that.. can i put an varible or a string in a print()?
like this :
print(m)
or
print("you've got "..m.." cakes")
thats the reason im using write
iv'e got an error when i send something from my other computer..
and its showing only when im using "print(hey)"
rednet.open("back")
term.clear()
term.setCursorPos(1,1)
i, m = rednet.receive()
write("van "..i.."")
print("hey")
write(m)
beside that.. can i put an varible or a string in a print()?
like this :
print(m)
or
print("you've got "..m.." cakes")
thats the reason im using write
theoriginalbit 19 Jan 2013
yes you can use variables inside of print... and you can concatenate strings around the variable... just make sure that the variable actually has something inside of it...
what is the exact error?
what is the exact error?
phaleron 19 Jan 2013
thanks for the fast reply!
my error is
"startup"6" attempt to call string"
(ps. im dutch.. sorry for the bad english )
my error is
"startup"6" attempt to call string"
(ps. im dutch.. sorry for the bad english )
crazyguymgd 19 Jan 2013
phaleron 19 Jan 2013
uhmm.. thats weird..
the one that is sending is:
term.clear()
term.setCursorPos(1,1)
rednet.open("back")
print("Mail box")
print()
write("Name: ")
n=read()
write("to: ")
i=tonumber(read())
print("message:")
print()
m=read()
rednet.send(i, m)
i think its something with "tonumber()" .. i dont know of that is true..
the one that is sending is:
term.clear()
term.setCursorPos(1,1)
rednet.open("back")
print("Mail box")
print()
write("Name: ")
n=read()
write("to: ")
i=tonumber(read())
print("message:")
print()
m=read()
rednet.send(i, m)
i think its something with "tonumber()" .. i dont know of that is true..
theoriginalbit 19 Jan 2013
tonumber will only error if you add any non-number characters...
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point...
Edited by TheOriginalBIT, 19 January 2013 - 11:42 PM.
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point...
Edited by TheOriginalBIT, 19 January 2013 - 11:42 PM.
remiX 19 Jan 2013
The tonumber() is needed because you need to convert the string of input (i) to a number in order to send a message to that PC/turtle via rednet.
On the other hand, your code has no errors...
This is exactly right to concatenate a string and a variable.
Before that, maybe add a print(type(m)) to see if it's a string or whatever.
PS: Please use [code]code here...[/code] tags
On the other hand, your code has no errors...
This is exactly right to concatenate a string and a variable.
print("you've got "..m.." cakes")
Before that, maybe add a print(type(m)) to see if it's a string or whatever.
PS: Please use [code]code here...[/code] tags
phaleron 19 Jan 2013
TheOriginalBIT, on 19 January 2013 - 11:41 PM, said:
tonumber will only error if you add any non-number characters...
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point...
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point...
yeah, i know.. so maybe the receiver must convert the "tonmuber" to a string again?
Doyle3694 19 Jan 2013
You have a variable, or a string rather called "print" somewhere on your computer.
theoriginalbit 19 Jan 2013
phaleron, on 19 January 2013 - 11:45 PM, said:
TheOriginalBIT, on 19 January 2013 - 11:41 PM, said:
tonumber will only error if you add any non-number characters...
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point...
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point...
yeah, i know.. so maybe the receiver must convert the "tonmuber" to a string again?
phaleron 19 Jan 2013
TheOriginalBIT, on 19 January 2013 - 11:48 PM, said:
phaleron, on 19 January 2013 - 11:45 PM, said:
TheOriginalBIT, on 19 January 2013 - 11:41 PM, said:
tonumber will only error if you add any non-number characters...
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point...
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point...
yeah, i know.. so maybe the receiver must convert the "tonmuber" to a string again?
phaleron 19 Jan 2013
it works now!.
first what i have done whas removed print() out of
print("message:")
print() -- this one removed
m=read()
and then i rebooted the computers
so helpfull!
thanks guys!
first what i have done whas removed print() out of
print("message:")
print() -- this one removed
m=read()
and then i rebooted the computers
so helpfull!
thanks guys!
phaleron 20 Jan 2013
there is only one problem left
I want to send i, m and n with
rednet.send(i, m, n)
when i do something like this
write("name ")
n=read()
then when i send Varible "n" there stands a number 3.
do you guys know a solusion?
I want to send i, m and n with
rednet.send(i, m, n)
when i do something like this
write("name ")
n=read()
then when i send Varible "n" there stands a number 3.
do you guys know a solusion?
theoriginalbit 20 Jan 2013
phaleron, on 20 January 2013 - 12:05 AM, said:
there is only one problem left
I want to send i, m and n with
rednet.send(i, m, n)
when i do something like this
write("name ")
n=read()
then when i send Varible "n" there stands a number 3.
do you guys know a solusion?
I want to send i, m and n with
rednet.send(i, m, n)
when i do something like this
write("name ")
n=read()
then when i send Varible "n" there stands a number 3.
do you guys know a solusion?
Sending end
-- read the variables here rednet.send( i, textutils.serialize( {m,n} ) )
Receiving end
-- receive rednet msgTable = textutils.unserialize( receivedMsg ) m = msgTable[1] n = msgTable[2]
This will make a table of all the items you want to send by turning it into a string and sending it... Then at the other end will turn it back into a table where you can use it.