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

textutils.un/serialize problem

Started by AlkamlBan, 10 July 2014 - 09:38 PM
AlkamlBan #1
Posted 10 July 2014 - 11:38 PM
So I was trying to do a filesharing program using textutils.serialize(). Here is the code for the sender:

rednet.open("right")
write("Enter file name: ")
fName = read()
copy = textutils.serialize(fName)
rednet.send(13, copy)

And here is the code for the receiver:

rednet.open("left")
senderId, program = rednet.receive()
myCopy = textutils.unserialize(program)
shell.run(myCopy)

But I get the following error at the receiver:
No such program <_</>
But I don't know why
Saldor010 #2
Posted 10 July 2014 - 11:45 PM
First of all, do you have a program at the receiver named "MyCopy"? Second of all, you need to put quotations around "myCopy" in shell.run, like this


shell.run("myCopy")

And your program can check if "myCopy" exists by doing


if fs.exists("myCopy") then
  -- If it exists
else
  -- If it doesn't
end
Edited on 10 July 2014 - 09:46 PM
Lyqyd #3
Posted 11 July 2014 - 12:01 AM
The serialization functions are meant to turn tables into strings and back. They're not what you want to use here. Look into the fs API.
flaghacker #4
Posted 11 July 2014 - 07:58 AM
First of all, do you have a program at the receiver named "MyCopy"? Second of all, you need to put quotations around "myCopy" in shell.run, like this


shell.run("myCopy")

And your program can check if "myCopy" exists by doing


if fs.exists("myCopy") then
  -- If it exists
else
  -- If it doesn't
end

I don't think he wants to run "myCopy", he wants to run the content of the variable myCopy. In this case he wants to open the filename he received with rednet.

@OP Delete the textutils functions and pass the received variables to the rednet.send and shell.run functions directly.