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

Quick Disk question

Started by grand_mind1, 19 January 2013 - 04:23 PM
grand_mind1 #1
Posted 19 January 2013 - 05:23 PM
Just a very quick and simple question for you pros out there. I was browsing the computercraft wiki and stumbled upon a page that was very important to my next project. Of course I forgot it and now that I am starting on my new project I need to find it again or for someone to tell me how to make a computer read information on a disk. If someone could be so kind as to link me to this page or to answer my question I would be very happy. Help is appreciated!
Thanks! :D/>
Dlcruz129 #2
Posted 19 January 2013 - 05:34 PM
Try the fs API.
remiX #3
Posted 19 January 2013 - 11:49 PM
Try the fs API.

Link

A file can be read by using the above API.


hRead = assert(fs.open("disk/fileName", "r")) -- disk/ is showing us that it's on the disk, fileName is the name of the file. "r" is the mode to open in, "read"
-- assert is for if the file is unable to open, it will error out.
line = hRead.read() -- or readAll() to get all information in the file
hRead.close()
print(line)