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

fs.write() not cooperating?

Started by moneymaster2012, 22 December 2015 - 12:14 AM
moneymaster2012 #1
Posted 22 December 2015 - 01:14 AM
Let the code explain the question:


	h = peripheral.wrap("bottom")
	print("Please enter blank data disk")
  
	os.pullEvent("disk")
	h = fs.open("disk/card","r")
	
	h.writeLine("123")				  --This is where the computer says the error is
	h.close()
	disk.eject("bottom")

Did I open my file correctly? My file is 'card' in the disk directory, except it hasn't been made yet. I want to make it with this program.
Dog #2
Posted 22 December 2015 - 01:32 AM
You're opening the file for reading (using "r") - you want to open the file for writing (use "w")
Creator #3
Posted 22 December 2015 - 12:33 PM
Take a look at the wiki page. More precisely this one.
Edited on 22 December 2015 - 11:34 AM