Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require "component"
- local tape = component.tape_drive
- local tArgs = {...}
- -------------------------------------------
- local function rezero()
- tape.seek(0-tape.getSize())
- end
- local function write(file)
- rezero()
- local fobj = io.open(file,"r")
- text = fobj:read("*a")
- fobj:close()
- print(text:len())
- local byte = text:byte(1)
- local n = 1
- repeat
- tape.write(byte)
- n = n + 1
- byte = text:byte(n)
- until byte == nil
- end
- local function read(amount)
- rezero()
- local outstr = ""
- repeat
- outstr = outstr..string.char(tape.read())
- amount = amount - 1
- until amount == 0
- local fobj = io.open(tArgs[3],"w")
- fobj:write(outstr)
- fobj:close()
- end
- if tArgs[1] == "read" then
- read(tArgs[2])
- elseif tArgs[1] == "write" then
- write(tArgs[2])
- end
Advertisement
Add Comment
Please, Sign In to add comment