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

Tabels and File System

Started by Nisutec, 29 May 2017 - 10:59 AM
Nisutec #1
Posted 29 May 2017 - 12:59 PM
Hello,
How i can upload a tabel like
test = {"test1", "test2", "test3"}
to a file system ?
And how i can download the tabel after that to my program ?
Lyqyd #2
Posted 29 May 2017 - 09:22 PM
Moved to Ask a Pro.
Bomb Bloke #3
Posted 30 May 2017 - 03:26 AM
Using the fs and textutils APIs;

Saving:
local myTable = {"test1", "test2", "test3"}

local outputFile = fs.open("someFile.txt", "w")
outputFile.writeLine( textutils.serialise( myTable ) )
outputFile.close()

Loading:
local inputFile = fs.open("someFile.txt", "r")
local myTable = textutils.unserialise( inputFile.readAll() )
inputFile.close()
Nisutec #4
Posted 09 June 2017 - 08:13 PM
thenks for help