setting up large arrays

Previous topic - Next topic

Gary

I have a program I am working on that requires a few very large arrays to be set up on start up as look up tables. The amount of data in each of them is anything up to 200,000 entries.

I have the entries in a text document ready to paste into a DIMDATA line but it looks like GLBasic can't handle really really long line in the editor and just locks up when I paste the data in

Is there any other solution to my problem without having to resort to reading in the data from a file at start up and also can GLB handle arrays of that size?

Thanks
Gary

spacefractal

You can't just read them as data from the txt file directly?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Gary

would rather have them hidden away from prying eyes and being accidentally deleted or edited but will go for the load option if thats the only way

Gary

trying to set them up via the data file but seem to be having issues opening the file

my code is

Code (glbasic) Select
OPENFILE(1,"47.txt",1)
FOR a = 0 TO 40
READLONG 1,temp%
win47[a] = temp%
NEXT
CLOSEFILE 1


to open and read the file attached which was generated by another GLB program to contain 40 longs but I am getting a error of No File. The file is in the right directory and exists so at a bit of a loss where I'm going wrong


spacefractal

You would end up using double memory using large data which is not designed in that way. Large data is also better from data files really. You can also crypt or hash them eventually.

I'm normally use READLINE using a string and then pass to a variable.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Ian Price

Yep. READLINE from a .txt file into an array is how I'd do it too.
I came. I saw. I played.

bigsofty

You could encode them onto a bitmap and then just read it in, then decode the bitmap a rgba pixels as a 32bit number. This would be quite fast a reading it in and double as a simple encryption. Just an idea.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Slydog

#7
Gary, to check if the file exists in your current directory, use (copied from the GLBasic User Manual):

Code (glbasic) Select
ok=DOESFILEEXIST("test.txt")
IF ok
PRINT "Test.txt exists", 100, 100
ELSE
PRINT "Test.txt does not exist", 100, 100
ENDIF


You may not be reading from the directory you think you are.
Try specifying an absolute path for testing.
Or use the GETCURRENTDIR$() to see which one you're in.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

spacefractal

I'm did the bitmap thing for a H.E.R.O in the past :-).

The main issue can been lost of depth with 16bit graphics, which can cause imprecise, which I'm also seen that in that game. So it's does have issues on its own.

But using data with large data is nowhere good idea.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Kitty Hello

Write the data to a cache file in binary format, maybe?

Gesendet von meinem GT-N7100 mit Tapatalk