I agree with Brian: if you are moving large amounts of data to/from disk and they are arranged in a predictable way, READ FILE# and WRITE FILE# are your friends. I have found it possible to read a single- precision floating point array containing 48 million elements from disk into memory (or vice versa) in a few seconds. -- Mark Chappell On Nov 6, 2008, at 2:19 PM, Brian Stevens wrote: > > On Nov 6, 2008, at 9:47 AM, Peter wrote: > <snip> >> Or is there a more modern way, this just seems clunky > > That code is just inefficient and a solution has nothing to do with > "modern" code. It will do approximately 3,800 Writes when it can be > done in 1 Write. > > The method is to pass the address of the array and do a Write for > the entire length of the array. The example below ( hacked together > quickly, so review carefully ) is a single dimension array but multi- > dimension is just a matter of calculating the size of the array ( or > hard-coding ) and using it. This uses an FSSpec but that is not the > example's focus. > > '------------ > begin record Stuff > dim as str31 size > dim as long length > end record > > begin globals > > dim as Stuff StockR(10) > dim as FSSpec fs > end globals > > //Clear array and load with test data > BlockZero(@StockR( 0 ),sizeof( Stuff ) * 11 ) > StockR.size(3) = "large" > StockR.length(3) = 12345 > > // Write to TestFilePB > fn FSMakeFSSpec( system( _aplVRefNum ), system( _aplParID ), > "TestFilePB", @fs ) > open "O",#1,@fs > Write File #1,@StockR(0), sizeof ( Stuff ) * 11 // write out entire > array in one Write File > Close #1 > > // Read TestFilePB > open "I",#1,@fs > Read File #1,@StockR(0), sizeof ( Stuff ) * 11 > Close #1 > > print StockR.size(3),StockR.length(3)// prove it is there > print StockR.size(0),StockR.length(0)// prove these are zeroed > > > do > > handleevents > until gFBquit > > '------------- > > > Brian S. > > -- > To unsubscribe, send ANY message to: futurebasic-unsubscribe@... >