Changeset 72 for Generics/TemplateGenerics/Demo/UMainForm.pas
- Timestamp:
- Oct 28, 2010, 4:52:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Demo/UMainForm.pas
r71 r72 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, ListInteger, ListString ;9 ComCtrls, ListInteger, ListString, DictionaryString; 10 10 11 11 type … … 14 14 15 15 TMainForm = class(TForm) 16 ButtonDictionaryString: TButton; 16 17 ButtonIntegerList: TButton; 17 18 ButtonStringList: TButton; 18 19 MemoOutput: TMemo; 20 procedure ButtonDictionaryStringClick(Sender: TObject); 19 21 procedure ButtonIntegerListClick(Sender: TObject); 20 22 procedure ButtonStringListClick(Sender: TObject); … … 46 48 begin 47 49 MemoOutput.Clear; 48 WriteLn('T IntegerListtest');50 WriteLn('TListInteger test'); 49 51 List := TListInteger.Create; 50 52 with List do try 51 SetArray([10, 20, 30, 40]);53 AddArray([10, 20, 30, 40]); 52 54 WriteLn('Implode: ' + Implode(',', IntToStr)); 53 55 Clear; … … 68 70 end; 69 71 72 function StringPairToStr(Pair: TPairString): string; 73 begin 74 Result := Pair.Key + ':' + Pair.Value; 75 end; 76 77 procedure TMainForm.ButtonDictionaryStringClick(Sender: TObject); 78 var 79 Dictionary: TDictionaryString; 80 begin 81 MemoOutput.Clear; 82 WriteLn('TDictionaryString test'); 83 Dictionary := TDictionaryString.Create; 84 with Dictionary do try 85 Add('Key1', 'Value1'); 86 Add('Key2', 'Value2'); 87 Add('Key3', 'Value3'); 88 WriteLn('Implode: ' + Implode(',', StringPairToStr)); 89 WriteLn('Values[Key2]: ' + Values['Key2']); 90 WriteLn('Values[Key2] = None'); 91 Values['Key2'] := 'None'; 92 WriteLn('Values[Key2]: ' + Values['Key2']); 93 WriteLn('Values[Key0]: ' + Values['Key0']); 94 WriteLn('Keys[2]: ' + Keys[2]); 95 finally 96 Free; 97 end; 98 end; 99 70 100 function StrToStr(Value: string): string; 71 101 begin … … 78 108 begin 79 109 MemoOutput.Clear; 80 WriteLn('T StringListtest');110 WriteLn('TListString test'); 81 111 List := TListString.Create; 82 112 with List do try 83 SetArray(['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven']);113 AddArray(['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven']); 84 114 WriteLn('Count: ' + IntToStr(Count)); 85 115 WriteLn('Implode: ' + Implode(',', StrToStr));
Note:
See TracChangeset
for help on using the changeset viewer.