Rev 2 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 3 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | procedure FormShow(Sender: TObject); |
55 | procedure FormShow(Sender: TObject); |
56 | procedure BtnRandomClick(Sender: TObject); |
56 | procedure BtnRandomClick(Sender: TObject); |
57 | private |
57 | private |
58 | PleaseStop: boolean; |
58 | PleaseStop: boolean; |
59 | procedure ResetGui; |
59 | procedure ResetGui; |
- | 60 | procedure WaitMs(milliseconds: integer); |
|
60 | end; |
61 | end; |
61 | 62 | ||
62 | var |
63 | var |
63 | Form2: TForm2; |
64 | Form2: TForm2; |
64 | 65 | ||
Line 72... | Line 73... | ||
72 | type |
73 | type |
73 | ECodeTooLong = class(Exception); |
74 | ECodeTooLong = class(Exception); |
74 | 75 | ||
75 | { TForm2 } |
76 | { TForm2 } |
76 | 77 | ||
- | 78 | procedure TForm2.WaitMs(milliseconds: integer); |
|
- | 79 | var |
|
- | 80 | i: integer; |
|
- | 81 | begin |
|
- | 82 | for i := 0 to milliseconds div 10 do |
|
- | 83 | begin |
|
- | 84 | Sleep(10); |
|
- | 85 | Application.ProcessMessages; |
|
- | 86 | if PleaseStop or Application.Terminated then break; |
|
- | 87 | end; |
|
- | 88 | end; |
|
- | 89 | ||
77 | procedure TForm2.BtnStartClick(Sender: TObject); |
90 | procedure TForm2.BtnStartClick(Sender: TObject); |
78 | var |
91 | var |
79 | x: THT46F47; |
92 | x: THT46F47; |
80 | i, ci: Integer; |
93 | i, ci: Integer; |
81 | s: string; |
94 | s: string; |
Line 87... | Line 100... | ||
87 | BtnStop.Enabled := true; |
100 | BtnStop.Enabled := true; |
88 | Memo2.Enabled := false; |
101 | Memo2.Enabled := false; |
89 | BtnRandom.Enabled := false; |
102 | BtnRandom.Enabled := false; |
90 | 103 | ||
91 | x := THT46F47.Create; |
104 | x := THT46F47.Create; |
- | 105 | try |
|
- | 106 | x.OnWait := WaitMs; |
|
92 | 107 | ||
93 | s := ''; |
108 | s := ''; |
94 | ci := 0; |
109 | ci := 0; |
95 | for i := 1 to Length(Memo2.Text) do |
110 | for i := 1 to Length(Memo2.Text) do |
96 | begin |
111 | begin |
- | 112 | {$IFDEF UNICODE} |
|
- | 113 | if CharInSet(Memo2.Text[i], ['a'..'f', 'A'..'F', '0'..'9']) then |
|
- | 114 | {$ELSE} |
|
97 | if Memo2.Text[i] in ['a'..'f', 'A'..'F', '0'..'9'] then |
115 | if Memo2.Text[i] in ['a'..'f', 'A'..'F', '0'..'9'] then |
- | 116 | {$ENDIF} |
|
98 | begin |
117 | begin |
99 | s := s + Memo2.Text[i]; |
118 | s := s + Memo2.Text[i]; |
100 | end; |
119 | end; |
101 | if Length(s) = 2 then |
120 | if Length(s) = 2 then |
102 | begin |
121 | begin |
Line 148... | Line 167... | ||
148 | 167 | ||
149 | Memo2.Enabled := true; |
168 | Memo2.Enabled := true; |
150 | BtnRandom.Enabled := true; |
169 | BtnRandom.Enabled := true; |
151 | BtnStart.Enabled := true; |
170 | BtnStart.Enabled := true; |
152 | ResetGui; |
171 | ResetGui; |
- | 172 | finally |
|
- | 173 | FreeAndNil(x); |
|
- | 174 | end; |
|
153 | end; |
175 | end; |
154 | 176 | ||
155 | procedure TForm2.BtnStopClick(Sender: TObject); |
177 | procedure TForm2.BtnStopClick(Sender: TObject); |
156 | begin |
178 | begin |
157 | // TODO: actually we need to inform the THT46F47 object, so it can break out of a possible waiting loop |
- | |
158 | BtnStop.Enabled := false; |
179 | BtnStop.Enabled := false; |
159 | PleaseStop := true; |
180 | PleaseStop := true; |
160 | end; |
181 | end; |
161 | 182 | ||
162 | procedure TForm2.BtnRandomClick(Sender: TObject); |
183 | procedure TForm2.BtnRandomClick(Sender: TObject); |