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

accessing a table using the fs api

Started by darkmists, 26 November 2014 - 12:44 AM
darkmists #1
Posted 26 November 2014 - 01:44 AM
I am wondering how I would go about accessing a table from a file using fs?
valithor #2
Posted 26 November 2014 - 01:49 AM
I am wondering how I would go about accessing a table from a file using fs?

Assuming that you saved the file to the file in its serialized form using textutils.serialize(table), then you would be able to do something like this

file = fs.open("filename","r")
table = textutils.unserialize(file.readAll())
file.close()
KingofGamesYami #3
Posted 26 November 2014 - 01:54 AM
*note: do not use the variable table for storing data. It is an api. Also avoid global variables when at all possible.
darkmists #4
Posted 28 November 2014 - 02:44 AM
thank you