BCX Console Demonstration Program s115.bas

DIM I AS LONGLONG

MACRO TenMillion = 10 * 1000 * 1000

OPEN "Test" FOR BINARY NEW AS FP1

DIM A$ * TenMillion + 1           ' a VERY LARGE STRING 

! memset(A,65,TenMillion);         // memset is a lowercase  "C" stdlib func

                                   ' In this example, we set every byte in A$ 
PUT$  FP1, A$, LEN(A$)            ' to ASCII 65 ( the letter "A" ) 
CLOSE FP1                          ' then write A$ out to a file in one swoop 
' The whole process takes about 2 seconds 
' on my 300mhz Pentium 

I = LOF("TEST")                   ' So, how big is the file? 
PRINT "LENGTH OF TEST FILE IS", I  ' If it's TenMillion it worked 
KILL "TEST"                       ' Don't need the file anymore

Result:

LENGTH OF TEST FILE IS 10000000