📄 main.~pas
字号:
unit Main;interfaceuses SysUtils, Types, Classes, Variants, QGraphics, QControls, QForms, QDialogs, QStdCtrls;type TFavorateType = ( ftBook, ftVCD, ftOther ); TFavorateCollection = record ID: Integer; Date: string; Price: Real; case FavorateType: TFavorateType of ftBook: ( BookTitle: string[64]; Authors: string[64]; Publisher: string[64]; NumberOfPagers: Integer; ); ftVCD: ( MovieName: string[64]; Producer: string[64]; Director: string[32]; Actress: string[32]; Actor: string[32]; ); ftOther: ( ); end; TFrmMain = class(TForm) BtnShow: TButton; Memo: TMemo; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure BtnShowClick(Sender: TObject); private { Private declarations } FCollection: array of TFavorateCollection; procedure SetFavorateCollection(); public { Public declarations } end;var FrmMain: TFrmMain;implementation{$R *.xfm}procedure TFrmMain.FormCreate(Sender: TObject);begin SetLength( FCollection, 2 ); SetFavorateCollection();end;procedure TFrmMain.FormDestroy(Sender: TObject);begin FCollection := nil;end;procedure TFrmMain.SetFavorateCollection;begin FCollection[0].ID := 1; FCollection[0].Date := '20010401'; FCollection[0].Price := 46.00; FCollection[0].FavorateType := ftBook; FCollection[0].BookTitle := 'Kylix Programming: An Advanced Course'; FCollection[0].Authors := 'June HE'; FCollection[0].Publisher := 'China Railway Publishing House'; FCollection[0].NumberOfPagers := 435; FCollection[1].ID := 2; FCollection[1].Date := '20010401'; FCollection[1].Price := 55.00; FCollection[1].FavorateType := ftVCD; FCollection[1].MovieName := 'HIdden Tiger, Crotching Dragon'; FCollection[1].Producer := ''; FCollection[1].Director := 'Ann Lee'; FCollection[1].Actress := 'Ziyi Zhang'; FCollection[1].Actor := 'Runfa Zhou';end;procedure TFrmMain.BtnShowClick(Sender: TObject);var i: Integer; str: string;begin for i := Low( FCollection ) to High( FCollection ) do begin str := IntToStr( FCollection[i].ID ); case FCollection[i].FavorateType of ftBook: begin str := str + FCollection[i].BookTitle; Memo.Lines.Add( str ); str := ' Date Purchased: ' + FCollection[i].Date; Memo.Lines.Add( str ); str := ' Price: ' + FloatToStr( FCollection[i].Price ); Memo.Lines.Add( str ); str := ' Author(s): ' + FCollection[i].Authors; Memo.Lines.Add( str ); str := ' Publisher: ' + FCollection[i].Publisher; Memo.Lines.Add( str ); str := ' No. of pagers: ' + IntToStr( FCollection[i].NumberOfPagers ); Memo.Lines.Add( str ); end; ftVCD: begin str := str + FCollection[i].MovieName; Memo.Lines.Add( str ); str := ' Date Purchased: ' + FCollection[i].Date; Memo.Lines.Add( str ); str := ' Price: ' + FloatToStr( FCollection[i].Price ); Memo.Lines.Add( str ); str := ' Producer: ' + FCollection[i].Producer; Memo.Lines.Add( str ); str := ' Director: ' + FCollection[i].Director; Memo.Lines.Add( str ); str := ' Actor and Actress: ' + FCollection[i].Actor; str := ', ' + FCollection[i].Actress; Memo.Lines.Add( str ); end; ftOther: begin // Do nothing. end; end; end;end;end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -