Jump to content




Quick Disk question


  • You cannot reply to this topic
2 replies to this topic

#1 grand_mind1

  • Members
  • 207 posts

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

#2 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 19 January 2013 - 05:34 PM

Try the fs API.

#3 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 19 January 2013 - 11:49 PM

View PostDlcruz129, on 19 January 2013 - 05:34 PM, said:

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)






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users