Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Problem with large text file

Author
Message
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 18th Jul 2017 22:40 Edited at: 19th Jul 2017 23:17
never mind, I found my mistake. Thankyou
.
Kevin Picone
22
Years of Service
Recently Online
Joined: 27th Aug 2002
Location: Australia
Posted: 19th Jul 2017 05:19


does Readline() grab a row of text from the open file ? If so.. then that's the problem.. the problem is the fetch cost off the device, to counter this, load the file as a binary blob into a mem block then decode it once it's in memory.

PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 19th Jul 2017 07:39 Edited at: 19th Jul 2017 08:13
Yes, Readline pulls off the top line, and I think if it is called again it pulls off the second line, third line etc.


Any example you could provide? Or rough outline ?
.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 19th Jul 2017 08:57
Can you post the text file? (Maybe compress it and post it)
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 19th Jul 2017 19:21
do you need to load/open it every time? can't you just leave it open?
so load/open it at the start of your code and then in your function just read the desired line(s)
life\'s one big game
spec= 2.6ghz, 1gb ram, 512mb gpu, directx 9.0c, dbpro and classic
jhanson
7
Years of Service
User Offline
Joined: 19th Jun 2017
Location: USA
Posted: 19th Jul 2017 21:10
What actually happens when you try to load it? Does your game crash, or does it just take a really long time?

Maybe you could load it in chunks. Like split the file up into 4 or 5 smaller files and load those.
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 19th Jul 2017 22:14 Edited at: 19th Jul 2017 23:21
oops, I found my mistake.

I put - CreateMemblockFromFile( 4444, "200K words." )

instead of -

CreateMemblockFromFile( 4444, "200K words.txt" )

Do you see the difference? I left out .txt

(I left out the '.txt.) and the AppGameKit gave me no error message about it
.

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Jul 2017 00:20
it would return zero
Kevin Picone
22
Years of Service
Recently Online
Joined: 27th Aug 2002
Location: Australia
Posted: 20th Jul 2017 05:49
Quote: "Any example you could provide? Or rough outline ?"


Assuming Readline() is able to long lines, then if you pre-process your dictionary and replace all the EOF's characters (10 & 11) with some other ASCII symbol in notepad. So you'd replace the 10's and 13's with say the pipe character | doesn't matter what it is as long as it's not naturally present in the file. Once you'd done this, you should then be able to load the whole line into a single string, then cut it up with the string functions. Which is easier than mem blocks, but it depends on the what is going to used for. If you'rre going to search / sort this stuff, then a custom structure is probably the best bet to avoid the string function overhead.

PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code

Login to post a reply

Server time is: 2024-11-24 12:07:09
Your offset time is: 2024-11-24 12:07:09