View difference between Paste ID: 1Rgt3QPL and xjBgXmfy
SHOW: | | - or go back to the newest paste.
1
----
2
--Original compile and run source code developed by Pharap
3
--http://www.computercraft.info/forums2/index.php?/user/3218-pharap/
4
--
5
--The original source can be found here:
6
--Compile.lua: http://pastebin.com/S520NYMV
7
--Run.lua: http://pastebin.com/xjBgXmfy
8
---
9
10
--Argument Checking--
11
local args = {...}
12
if(#args<1)then error("Need one argument",0) end
13
if(not fs.exists(args[1]))then error("Invalid filename",0) end
14
15
16
--Functionality--
17
local function loadfile(inFile)
18
	local data = {}
19
	local file = fs.open(inFile,"rb")
20
	local clock = os.clock() + 4.5
21
	for i = 1,fs.getSize(inFile)do
22
		data[i] = string.char(file.read()) 
23
		if(os.clock()>=clock)then
24
			os.queueEvent"" -- Prevents 5 second loop. 
25
			coroutine.yield() -- Suggested by pingoleon60 and theoriginalbit
26
			clock = os.clock() + 4.5
27
		end
28
	end
29
	file.close()
30
	return loadstring(table.concat(data))
31
end
32
33
loadfile(args[1])(select(2,unpack(args)))