Pandafuchs

PrintLogFile

Oct 17th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. myPrinter = peripheral.wrap( "printer_0" )
  2.  
  3. while true do
  4.     print("Moechten Sie die Logfile drucken [j/n]: ");
  5.     local input = read()
  6.     if input == "j" then
  7.         ready = myPrinter.newPage()
  8.         myPrinter.setPageTitle("ZugLog Hauptbahnhof")
  9.         local h = fs.open("disk/logfile", "r")
  10.  
  11.         local input = h.readLine()
  12.         local zeile = 1
  13.         while input ~= nil do
  14.             myPrinter.write( input  );
  15.             input = h.readLine()
  16.             myPrinter.setCursorPos(1, zeile)
  17.             zeile = zeile + 1
  18.         end
  19.         myPrinter.endPage()
  20.         fs.delete("disk/logfile")
  21.  
  22.         local file = fs.open("disk/logfile", "w")
  23.         file.writeLine("New Logfile created...")
  24.         file.close()
  25.         print("Datei wurde gedruckt... bitte aus dem Drucker entnehmen")
  26.     end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment