Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- http://nyelvek.inf.elte.hu/leirasok/Lua/index.php?chapter=12#section_6
- --
- print( arg[0] )
- filename = "itr_ascii_minta.dat"
- -- Opens a file in read
- file = io.open(filename, "r")
- -- prints the first line of the file
- print("¤"..file:read().."¤\n")
- -- ...It offsets the cursor from the 25 positions prior to the end of file. The read function prints remainder of the file from seek position.
- file:seek("end",-25)
- print("×"..file:read("*a").."×\n")
- file:seek("set")
- wholeFile = file:read("*a")
- print(wholeFile)
- --[[
- Source:
- 301 Pontok
- 310 "pontszám szöveggel" 95.530 283.150 0.000 4315 0 0
- 301 Vonalak
- 301 Feliratok
- 340 150.400 170.250 0.0 1 10 100 4 0 0 0 szöveg szóközzel
- 341 253.470 214.660 0.0 1 105 1 1 1 0 0 0.0 1.00 1 1309 855 szöveg szóközzel2
- 301 Jelkulcsok
- 301 Ívek
- Destination
- '301' = {"Pontok", "Vonalak", "Feliratok", "Jelkulcsok", "Ívek"}
- '310' = {" "pontszám szöveggel" 95.530 283.150 0.000 4315 0 0"}
- ...
- ]]
- t = {}
- file:seek("set")
- for line in file:lines() do
- print(line)
- for k, v in string.gfind(line, "(%a+) (.+)") do
- t[k] = v
- end
- end
- -- closes the opened file
- file:close()
- t = {}
- s = "from=world, to=Lua"
- for k, v in string.gmatch(s, "(%w+)=(%w+)") do
- t[k] = v
- end
- for k, v in pairs(t) do
- print(k, v)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement