Quote:

but with current bulk methods it seems rather out there.



Not too sure what you mean. Reading and writing blocks is unaffected. You simply read or write the blocks at the current position in the file which is a more natural way of coding.

If you are working with binary files then at some point you are going to want to handle specific data types, like longs and decimals. You could convert these and write small blocks, but it would make more sense to do something like:
Code:

; Create binary file handler
$oKiXbinFile=createobject("kixbin.file")

; Open student data file.
$oFile=$oKiXbinFile.FileOpen("c:\data\students.dat",2+4) ; Open file for both read (2) and write (4).

$iRecordSize=512 ; Student records are 512 bytes long
$iStudentNo=56 ; Unique student number
$iRecordOffset=($iStudentNo-1)*$iRecordSize

$lYear=2004
$iAge=16
$dAverageScore=73.28
$sClass="Physics L6"

; Move file cursor to student record
$oFile.Seek($iRecordOffset,SEEK_SET)

; Update student record
$oFile.Write($lYear)
$oFile.Write($iAge)
$oFile.Write($dAverageScore)
$oFile.Write($sClass)

; Flush changes to disk and close stream
$oFile.Close()



Unfortunately, KiXtart does not support all basic types, so it will probably require coercing:
Code:
$oFile.WriteLong($lYear)
$oFile.WriteShort($iAge)
$oFile.WriteDouble($dAverageScore)
$oFile.WriteString($sClass)



Or, taking the values from VarType:
Code:
$oFile.Write($lYear, 2)         ; Integer
$oFile.Write($iAge,17) ; Byte
$oFile.Write($dAverageScore,5) ; Double
$oFile.Write($sClass) ; String (default)



Blocks of course will work similarly:
Code:
$oFile.ReadBlock(256) ; Read up to 256 bytes and return as an array, array will be smaller on EOF.
$oFile.WriteBlock($aiData) ; Write array.
$oFile.WriteBlock($aiData,256) ; Write 256 bytes from $aiData, pad with zeros if $aiData is shorter.




Quote:

reading the docs, the normal trunc just sets the EOF which ain't truly truncing the data.




Hmm. Maybe it's a windows thing. truncate()/ftruncate() will (normally) set the file length, truncating the file and releasing unused frames.

Quote:

...I need to instruct ppl to check the file with getfilesize...




Or:
Code:
$oFile.seek(0,SEEK_END) /* go to end of file */
$iFileSize=$oFile.Tell() /* Get cursor position, which == file size in bytes */