ptokax and Lua 4.0
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

ptokax and Lua 4.0

Started by c h i l l a, 06 January, 2004, 21:27:11

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

c h i l l a

so I have this huge file with 100.000 entries  for a trivia bot, well I decided not to load all of it into memory.

but i also don't want to run through the file again and again, when getting new questions...

so thaught, why not seek through the file on startup, store the seeks in a table and... then get those random seeks, and read from line.


okey, problem is, actually only, that LUA will always set the curser, to the beginning of a line = read(handle)  but ptokax won't, any idea why, I get 2 different results when I use ptokax and the other time lua 4.0.

here is my func.


function ReadSeek(QFile)
	handle2 = openfile(QFile,"r")
	if handle2 then
		local line = read(handle2)
		while line do
			local sek = seek(handle2,"cur")
			line = read(handle2)
			tinsert(seeks,sek)
		end
		closefile(handle2)
	end
	local handle = openfile("testseek.txt","w")
	for i = 1,getn(seeks) do
		write(handle,seeks[i].."\r\n")
	end
	closefile(handle)
end

other question..  does a set seek, take as long as a

local line = openfile(blabla)
var = 0
while line do
var = var + 1
if var == XX then
Line to get
end
end

c h i l l a

nevermind got it myself :)

SMF spam blocked by CleanTalk