Here's something I posted in another thread about streams:
BlitzMax defaults to the endianness your CPU uses, LittleEndian for Intel and BigEndian for PowerPC. You can specify which one to use.
testfile$ = "data_12345678.bin"
TS:TStream = WriteStream( testfile )
WriteInt( TS, $12345678 )
CloseStream TS
TS = ReadStream( testfile )
DefaultEndian = ReadInt( TS )
CloseStream TS
TS = BigEndianStream( ReadStream( testfile ) )
BigEndian = ReadInt( TS )
CloseStream TS
TS = LittleEndianStream( ReadStream( testfile ) )
LittleEndian = ReadInt( TS )
CloseStream TS
DeleteFile testfile
Print
Print " Test endianness:"
Print
Print " Default " + Hex( DefaultEndian )
Print " Little " + Hex( LittleEndian )
Print " Big " + Hex( BigEndian )
|