Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(str, ts)
- -- 引数がないときは空tableを返す
- if ts == nil then return {} end
- local t = {} ;
- i=1
- for s in string.gmatch(str, "([^"..ts.."]+)") do
- t[i] = s
- i = i + 1
- end
- return t
- end
- local function write1()
- local f = io.open("last.dat", "w")
- f:write("1,2,3,N")
- f:close()
- end
- local function write2()
- local f = io.open("last.dat", "w")
- f:write("3,2,1,N")
- f:close()
- end
- local function read()
- local f = io.open("last.dat", "r")
- for line in f:lines() do
- local strs = split(line, ",")
- for i = 1, #strs do
- print(strs[i])
- end
- end
- f:close()
- end
- local quitFlag = false
- local function quitProcess()
- local event, param1 = os.pullEvent()
- if param1 == "q" then
- write2()
- quitFlag = true
- end
- end
- while not quitFlag do
- parallel.waitForAny(quitProcess)
- read()
- os.sleep(0.05)
- end
Add Comment
Please, Sign In to add comment