home *** CD-ROM | disk | FTP | other *** search
- { DEMOTBUF.PAS }
- var
- PhoneBook : PCollection;
- PhoneBookFile : TBufStream;
-
- ...
-
-
- { TPersonInfo is a collection object holding name and address information }
- procedure TPersonInfo.Store ( var S : TStream );
- begin
-
- S.Write( Name, SizeOf( Name ));
- S.Write( Address, SizeOf( Address ));
- S.Write( City, SizeOf( City ));
- S.Write( State, SizeOf( State ));
- S.Write( Zip, SizeOf( Zip ));
- S.Write( Age, SizeOf( Age ));
-
- end;
-
-
- constructor TPersonInfo.Load ( var S : TStream );
- begin
-
- S.Read( Name, SizeOf( Name ));
- S.Read( Address, SizeOf( Address ));
- S.Read( City, SizeOf( City ));
- S.Read( State, SizeOf( State ));
- S.Read( Zip, SizeOf( Zip ));
- S.Read( Age, SizeOf( Age ));
-
- end;
-
- ...
-
- { Register the PersonInfo object type }
- RegisterType( RPersonInfo );
-
- { Open the stream file }
- PhoneBookFile.Init('FONEBOOK.DAT', stCreate, 1024 );
-
- { Tell the PhoneBook collection to put itself to the stream }
- PhoneBookFile.Put( PhoneBook );
-
- { Close the file }
- PhoneBookFile.Done;
-
-