PDA

Click to See Complete Forum and Search --> : Large arrays


pollier
Dec 7th, 2000, 10:07 PM
I have a large four-dimensional array in my game and I need the most efficient way of saving/loading it possible. I am currently using four For..Next loops but I'm sure there's a faster way. Anyone?

Fox
Dec 8th, 2000, 12:01 AM
Sure ;)

Dim Array() as Whatever
Dim Size as Long
Dim FileNum as Integer

Sub Form_Load()
size = 100000
Redim array(size)
End Sub

Save(FileName as string)
Filenum=freefile
Open filename for binary as filenum
put filenum,,size
put filenum,,array
close filenum
end sub

Save(FileName as string)
Filenum=freefile
Open filename for binary as filenum
get filenum,,size
redim array(size)
get filenum,,array
close filenum
end sub


have fun :)

HarryW
Dec 8th, 2000, 12:02 AM
Saving it to a file? Well just do this:


Open strFileName For Binary As #1
Put #1, , ReallyBigArray
Close #1


You don't have to use loops, just stick the whole thing in like that.

Fox
Dec 8th, 2000, 12:10 AM
I was faster :D

HarryW
Dec 8th, 2000, 12:42 AM
*D'oh*

Hehe ;)

Koralt
Dec 9th, 2000, 09:14 PM
What exactly are you using this four-dimensional array for?

oetje
Dec 10th, 2000, 01:52 AM
Originally posted by Fox
Sure ;)

Dim Array() as Whatever
Dim Size as Long
Dim FileNum as Integer

Sub Form_Load()
size = 100000
Redim array(size)
End Sub

Save(FileName as string)
Filenum=freefile
Open filename for binary as filenum
put filenum,,size
put filenum,,array
close filenum
end sub

Save(FileName as string)
Filenum=freefile
Open filename for binary as filenum
get filenum,,size
redim array(size)
get filenum,,array
close filenum
end sub


have fun :)
You have 2 Save functions in your code. The 2nd one should be Open.:)