screenres 512,384,32
static shared as ubyte array() '8GB
redim array(8000000000)
open "test8gb.txt" for binary access write as #1
put #1,,array()
close #1
beep
sleep
#include "crt.bi"
#include "file.bi"
#macro Csave(filename,arr)
Scope
Dim As file Ptr f = fopen((filename), "wb")
fwrite(Cptr(Typeof(arr) Ptr,@arr(lbound(arr))),sizeof(arr),ubound(arr)-lbound(arr)+1,f)
fclose(f)
End Scope
#endmacro
#macro Cload(filename,arr)
Scope
Dim As file Ptr f = fopen((filename), "rb")
fread(Cptr(Typeof(arr) Ptr,@arr(lbound(arr))),sizeof(arr),ubound(arr)-lbound(arr)+1,f)
fclose(f)
End Scope
#endmacro
dim as long size=500000000
print "size ";size/1000000000;" gb"
redim as ubyte u(size)
clear u(0),4,size
for n as long=1000000 to 1000050
print u(n);" ";
next
print
print "saving"
csave("ctest.txt",u)
print "saved"
print "file length ";filelen("ctest.txt")
redim as ubyte v(size)
print "re-loading"
cload("ctest.txt",v)
print "Loaded"
print
for n as long=1000000 to 1000050
print v(n);" ";
next
print
kill "ctest.txt"
print iif(filelen("ctest.txt")=0,"OK","Delete file manually")
sleep