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

[Request] Make "edit" add print(" and ") at the start and end of every line.

Started by Someguyfromplaces, 27 March 2012 - 07:50 PM
Someguyfromplaces #1
Posted 27 March 2012 - 09:50 PM
I need someone to edit the built-in program "edit" and at every line it needs to add an invisible print(" at the start of every line and ") at the end of every line . So when you run the program it will write the file back to you.

———————————————————————————————————————————

And if you want to be a super clever cloggs… Can you make it so when the created file is read, it has a scrollbar so you can scroll through text and read large walls of text.

If you don't want to do that, just make it so if the text is above the screen's height limit it will say something like "Use a monitor!" and "Use a bigger monitor!"
EatenAlive3 #2
Posted 27 March 2012 - 10:05 PM
Your first paragraph was a little unclear. Why would you need to add an invisible statement after every line? Just create a program that adds " at the start of every line and " to the end of each line after saving. Since copy and paste has not been added to Edit, adding invisible lines would do nothing.

As for the last paragraph, you can already scroll through lines with the up and down arrow keys. If you mean a scroll-bar like the ones in wordpad, it won't work. Mouse input is not possible in the current computercraft build. Instead, you can edit files from outside of minecraft and save them to your saves/saveName/computer/id# folder.
MysticT #3
Posted 27 March 2012 - 11:32 PM
If you need to print all the text from a file you can make a program to do that. It would be really easy, something like:

local tArgs = { ... }
if #tArgs == 0 or #tArgs > 1 then
  print("Usage: readfile <filename>")
  return
end
local file = fs.open(tArgs[1], "r")
if file then
  local sLine = file.readLine()
  while sLine do
    print(sLine)
    sLine = file.readLine()
  end
  file.close()
end
This would just print all the file (same that would happen adding the print's like you suggested). If you need to be able to scroll through the text, you should have to save the text and print it like the edit programs does.