Advertisement
shadowkat1010

micrOS sked.lua

Sep 25th, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. b={}
  2. l=1
  3. function ctr() s=syscall.execute("stdin_read") return s end
  4. function p(d) syscall.execute("stdout_write",d) end
  5. while true do
  6. c=ctr()
  7. if c=="l" then for k,v in pairs(b) do p(v) end
  8. elseif c=="lc" then p(tostring(b[l]).."\n")
  9. elseif c=="s" then p">" l=tonumber(ctr())
  10. elseif c=="so" then p(l)
  11. elseif c=="a" then p":" c=ctr() repeat table.insert(b,l,c) l=l+1  c=ctr() until c=="."
  12. elseif c=="r" then p":" b[l]=ctr()
  13. elseif c=="d" then p(table.remove(b,l))
  14. elseif c=="o" then p">" rF=ctr() f=syscall.execute("fs_open",rF,"r") a="" repeat c=syscall.execute("fs_read",f) if c==nil then c="" end a=a..c until c=="" syscall.execute("fs_close",f) for L in a:gmatch("[^\r\n]+") do table.insert(b,l,L) l=l+1 end
  15. elseif c=="w" then p">" wT=ctr() f=syscall.execute("fs_open",wT,"w") for k,v in pairs(b) do syscall.execute("fs_write",f,v.."\n") end syscall.execute("fs_close",f)
  16. elseif c=="e" then cd="" for k,v in pairs(b) do cd=cd..v.."\n" end pcall(load(cd))
  17. elseif c=="q" then break else p"?" end end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement