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

Printing File Contents to the screen

Started by libraryaddict, 05 March 2012 - 03:45 PM
libraryaddict #1
Posted 05 March 2012 - 04:45 PM
Hey,

I was wanting to write a couple of programs which involved text dumping to screen.
But Im at a loss to a way to dump file contents to screen.
And a way to write it to file.

Could someone be nice and helpful and give me a program which does what I want it to do?
Im not talking about you writing the complete program.
But giving a program that shows me what I want so I can replicate it
Advert #2
Posted 05 March 2012 - 05:02 PM
So you want to dump the contents of a file to the screen?

You'd need fs/io.open, handle:readLine()/read("*l"), a loop, and print().

Open at your own risk:
Spoiler

local h = fs.open("file", "r")
repeat
 local line = h:readLine()
 print(line)
until not line
h:close()
libraryaddict #3
Posted 06 March 2012 - 06:49 AM
Thanks :unsure:/>/>