file.readline(number) ?
#1
Posted 17 December 2012 - 04:22 PM
note: i do not want to read the entire file at once as its huge ( MBs not KBs )
#2
Posted 17 December 2012 - 04:27 PM
Reference:
http://computercraft.info/wiki/IO_(API)
EDIT: Upon further investigation the file seek wouldn't have done what you wanted to.
#3
Posted 17 December 2012 - 04:33 PM
#4
Posted 17 December 2012 - 04:36 PM
etopsirhc, on 17 December 2012 - 04:33 PM, said:
ok here is one solution that I just thought of. At startup load the file into a table of the lines. then in the code to read from say like 50 to 100 you would do this
for = 50, 100 do line = tableName[i] -- do something with the line end
#5
Posted 17 December 2012 - 04:45 PM
basically this is for my printer presistance , cause if say the server crashes and i have to restart the program i want it to pick up from the line it left off on.
#6
Posted 17 December 2012 - 04:47 PM
etopsirhc, on 17 December 2012 - 04:45 PM, said:
basically this is for my printer presistance , cause if say the server crashes and i have to restart the program i want it to pick up from the line it left off on.
It makes sense why you don't want to load it all, but unless one of the other guys knows a way then loading it all at startup may be the only way to do it.
#7
Posted 17 December 2012 - 04:51 PM
#8
Posted 17 December 2012 - 04:56 PM
#9
Posted 17 December 2012 - 05:23 PM
#10
Posted 17 December 2012 - 05:46 PM
stuff = fileData[80]
fileData = nil
print(stuff)
#11
Posted 17 December 2012 - 08:20 PM
#12
Posted 17 December 2012 - 08:35 PM
#13
Posted 17 December 2012 - 08:55 PM
#14
Posted 17 December 2012 - 09:28 PM
TheOriginalBIT, on 17 December 2012 - 08:35 PM, said:
the first time i tried making one i decided to load phrased info into a 3d table, it loaded a line of text and searched though the line for 1's to get the block coords
it took over 5 hrs to finish reading the file, ><
i cut the file down a ton by doing that heavy part in java and writing out relative coords. so now i just load line, phrase it to 3 number and tell the turtle what to do , no extra pre-loading.
#15
Posted 17 December 2012 - 09:43 PM
etopsirhc, on 17 December 2012 - 09:28 PM, said:
TheOriginalBIT, on 17 December 2012 - 08:35 PM, said:
the first time i tried making one i decided to load phrased info into a 3d table, it loaded a line of text and searched though the line for 1's to get the block coords
it took over 5 hrs to finish reading the file, ><
i cut the file down a ton by doing that heavy part in java and writing out relative coords. so now i just load line, phrase it to 3 number and tell the turtle what to do , no extra pre-loading.
I also had to write a program in Java this semester at university, it had to calculate fan-in and fan-out data of classes. The requirement was that it had to read ~20,000 class files and calculate the data and then write out that data to a file, all under 10 seconds. I was helping people who were having issues with getting it under 10 seconds, some people were getting upwards of 5 minutes. Mine ran in 120milliseconds. 2nd fastest in the unit, guy that was better multithreaded and was writing while calculating, or something.
#17
Posted 17 December 2012 - 11:14 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











