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

Making program in program

Started by XMan3, 20 October 2014 - 05:38 PM
XMan3 #1
Posted 20 October 2014 - 07:38 PM
Well, I am trying to make File transfer system in Computercraft, I do not need any more knowledge of Rednet, but I am stuck in this thing:
Can I write program using string? Example:
If someone sends string: while true do
*Write the first line, while true do*
Then: print("HELLO WORLD!")
*Write the second line*
And: end
*Write the third line*

…Or…
If someone sends the whole program thing in one string: while true do print("HELLO WORLD!") end

So, is that possible?
Dragon53535 #2
Posted 20 October 2014 - 08:09 PM
It's possible both ways, however i believe the second is harder.

take a look into the fs API Here. More specificially fs.open

A small tutorial for the fs api is here.
Lyqyd #3
Posted 20 October 2014 - 08:25 PM
The second way is definitely easier. Read the file on one end, send the multiline string, receive it on the other end and write it to the file.
valithor #4
Posted 20 October 2014 - 08:50 PM
You could actually do this pretty easily by sending the program as a table then looping through the table. I know that this is how the edit program handles file saving.
KingofGamesYami #5
Posted 20 October 2014 - 08:55 PM
You could actually do this pretty easily by sending the program as a table then looping through the table. I know that this is how the edit program handles file saving.
Why not just send the entire string?
valithor #6
Posted 20 October 2014 - 08:57 PM
Right now my computers doesn't want to let me quote… but I was just offering another way to do it.