Changeset 128 for CoolStreaming/Demo/DynNumber/UMainForm.pas
- Timestamp:
- Jan 16, 2011, 4:31:02 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolStreaming/Demo/DynNumber/UMainForm.pas
r127 r128 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, UDynNumber, Math;9 ComCtrls, Spin, UDynNumber, Math; 10 10 11 11 type … … 16 16 Button1: TButton; 17 17 Button2: TButton; 18 Button3: TButton; 19 Button4: TButton; 18 20 Edit1: TEdit; 21 Edit2: TEdit; 22 Edit3: TEdit; 19 23 ListView1: TListView; 24 PageControl1: TPageControl; 25 SpinEdit1: TSpinEdit; 26 TabSheet1: TTabSheet; 27 TabSheet2: TTabSheet; 20 28 procedure Button1Click(Sender: TObject); 21 29 procedure Button2Click(Sender: TObject); 30 procedure Button3Click(Sender: TObject); 31 procedure Button4Click(Sender: TObject); 22 32 procedure FormCreate(Sender: TObject); 23 33 procedure FormDestroy(Sender: TObject); 24 34 private 25 { private declarations }26 35 public 27 36 DynamicNumber: TDynamicNumber; … … 44 53 Parts: array of Integer; 45 54 N: TDynamicNumber; 46 Line: string;47 55 NewItem: TListItem; 48 56 begin … … 51 59 ListView1.BeginUpdate; 52 60 ListView1.Clear; 53 for I := 0 to 10000do begin61 for I := 0 to SpinEdit1.Value do begin 54 62 N.Stream.Size := 0; 55 N.Write(I); 56 Line := ''; 57 N.Stream.Position := 0; 58 for J := 0 to N.Stream.Size - 1 do 59 Line := Line + IntToStr(Integer(N.Stream.ReadBit)); 63 N.WriteNumber(I); 60 64 NewItem := ListView1.Items.Add; 61 65 NewItem.Caption := IntToStr(I); 62 66 J := Floor(Log2(I)) + 1; 63 67 NewItem.SubItems.Add(FloatToStr(Round((1 - (J / N.Stream.Size)) * 100) / 100)); 64 NewItem.SubItems.Add( Line);68 NewItem.SubItems.Add(N.Stream.AsString); 65 69 end; 66 70 finally … … 79 83 MaxValue: Integer; 80 84 J: Integer; 81 Line: string;82 85 NewItem: TListItem; 83 86 N: TDynamicNumber; … … 91 94 ListView1.BeginUpdate; 92 95 ListView1.Clear; 93 for II := 0 to 20000do begin96 for II := 0 to SpinEdit1.Value do begin 94 97 I := II * Step; 95 98 // Write … … 109 112 J := Floor(Log2(I)) + 1; 110 113 NewItem.SubItems.Add(FloatToStr(Round((1 - (J / N.Stream.Size)) * 100) / 100)); 111 Line := ''; 112 N.Stream.Position := 0; 113 for J := 0 to N.Stream.Size - 1 do 114 Line := Line + IntToStr(Integer(N.Stream.ReadBit)); 115 NewItem.SubItems.Add(Line); 114 NewItem.SubItems.Add(N.Stream.AsString); 116 115 117 116 // Increment value … … 142 141 end; 143 142 143 procedure TMainForm.Button3Click(Sender: TObject); 144 var 145 N: TDynamicNumber; 146 begin 147 try 148 N := TDynamicNumber.Create; 149 N.Stream.Size := 0; 150 N.WriteNumber(StrToInt64(Edit1.Text)); 151 N.Stream.Position := 0; 152 Edit2.Text := N.Stream.AsString; 153 finally 154 N.Free; 155 end; 156 end; 157 158 procedure TMainForm.Button4Click(Sender: TObject); 159 var 160 N: TDynamicNumber; 161 begin 162 try 163 N := TDynamicNumber.Create; 164 N.Stream.AsString := Edit2.Text; 165 Edit3.Text := IntToStr(N.ReadNumber); 166 finally 167 N.Free; 168 end; 169 end; 170 144 171 procedure TMainForm.FormCreate(Sender: TObject); 145 172 begin
Note:
See TracChangeset
for help on using the changeset viewer.