kremnev8

answer ccompile

Feb 20th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. qs = ""
  2. ANSWERS = {""}
  3. OPENS = false
  4. cfgn = "/questions"
  5. fs = require("filesystem")
  6. --while true do
  7. function unstd()
  8. for h=1,200,1 do
  9. ms = fl:read()
  10. if ms == nil then
  11. break
  12. else
  13. if ms == "{" then
  14. OPENS = true
  15. for i=1,10,1 do
  16. --print(i)
  17. ms = fl:read()
  18. --print(ms)
  19. if string.sub(ms,1,1) == "#" then
  20. cmd = string.sub(ms,2)
  21. if string.sub(cmd,1,3) == "QS:" then
  22. qs = string.sub(cmd,4)
  23. --print("QS="..qs)
  24. ms = fl:read()
  25. --print(ms)
  26. elseif string.sub(cmd,1,3) == "A1:" then
  27. table.insert(ANSWERS,string.sub(cmd,4))
  28. NQ = 2
  29. for j=1,10,1 do
  30. if NQ == 4 then
  31. break end
  32. ms = fl:read()
  33. if string.sub(ms,1,1) == "#" then
  34. cmd = string.sub(ms,2)
  35. if string.sub(cmd,1,3) == "A"..tostring(NQ)..":" then
  36. NQ = NQ + 1
  37. table.insert(ANSWERS,string.sub(cmd,4))
  38. end
  39. end
  40. end
  41. end
  42. if ms == "}" then
  43. OPENS = false
  44. --print("breaked")
  45. break
  46. end
  47. end
  48. if OPENS then
  49. print("not closed question!")
  50. OPENS = false
  51. --else
  52. end
  53. print(qs)
  54. for i=1,#ANSWERS do
  55. print(ANSWERS[i])
  56. end
  57. --end
  58. end
  59. end
  60. end
  61. end
  62. end
  63.  
  64.  
  65. if fs.exists(cfgn) then
  66. if not fs.isDirectory(cfgn) then
  67. fl = io.open(cfgn,"r")
  68. unstd()
  69. else
  70. fl = io.open(cfgn,"w")
  71. fl:close()
  72. end
  73. end
Advertisement
Add Comment
Please, Sign In to add comment