FILE
is a type for working with binary file I/O on any platform. It can be used to access raw blocks of data, or structured blocks like records, and mixing there of.
type MsgHeader = Packed Record MsgFrom:String[36]; MsgTo:String[36]; Subject:String[72]; MsgSize:LongWord; End; var BFH:File; Msg:MsgHeader; Buf:TCharArray; NMW:Longint; Procedure AddToBody(S:String); var Offset,Len:LongWord; Begin Offset:=Length(Buf); Len:=Length(S); SetLength(Buf, Len 2 Offset); Move(S[1], Buf[Offset], Len); Move(#13#10, Buf[Offset Len], 2); End; Begin Msg.MsgFrom:='OZZ NIXON'; Msg.MsgTo:='ALL'; Msg.Subject:='WELCOME TO MY SYSTEM!'; Msg.MsgSize:=Length(Buf); AssignFile(BFH,'testfile.dat'); Rewrite(BFH, 1); // byte oriented reads and writes BlockWrite(BFH, Msg, SizeOf(MsgHeader), NMW); BlockWrite(BFH, Buf[0], Length(Buf), NMW); CloseFile(BFH); End.Source: Reserved Words