Code: |
{ You sometimes wish to store multiple information in a given class like in the example: alltogether when it belongs together. Thus accessing this information from out of the class can be achieved using property declaration. Its a good way to "clean your code" and make it as "logic" as possible. You also may have to store or load information from your class using file or stream technology. This can be done at once for the recorded information from within the given class. }
type TPersonRecord = Record FirstName: String; LastName: String; BirthDate: TDate; End;
TForm4 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private fActualUser: TPersonRecord; ... procedure SaveActualUser(S: TFileStream); // it's an example procedure LoadActualUser(S: TFileStream); ... public property FirstName: stringread fActualUser.FirstName write fActualUser.FirstName; property LastName : stringread fActualUser.LastName write fActualUser.LastName; property BirthDate: TDate read fActualUser.BirthDate write fActualUser.BirthDate; end;
procedure TForm4.SaveActualUser(S: TFileStream); begin // All that stuff at once in your Stream S.Write(fActualUser, SizeOf(fActualUser)) end;
procedure TForm4.LoadActualUser(S: TFileStream); begin // All that stuff at once back in your class S.Read(fActualUser, SizeOf(fActualUser)); end; |
https://delphiworld.narod
DelphiWorld 6.0
Просьба писать ваши замечания, наблюдения и все остальное,
что поможет улучшить предоставляемую информацию на этом сайте.
ВСЕ КОММЕНТАРИИ МОДЕРИРУЮТСЯ ВРУЧНУЮ, ТАК ЧТО СПАМИТЬ БЕСПОЛЕЗНО!