-
Notifications
You must be signed in to change notification settings - Fork 0
/
uListRandomUStrings.pas
59 lines (48 loc) · 1.17 KB
/
uListRandomUStrings.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
unit uListRandomUStrings;
interface
uses
Classes, SysUtils, uAnsiStrings, uListRandomBase;
type
TListRandomUStrings = class(TListRandomBase)
private
FDefault: UnicodeString;
FUStrings: TUnicodeStrings;
public
constructor Create(const AUStrings: TUnicodeStrings; AOwner: Boolean = False);
destructor Destroy; override;
//---
procedure Update;
function Next: UnicodeString;
//---
property List: TUnicodeStrings read FUStrings;
property DefaultValue: UnicodeString read FDefault write FDefault;
end;
implementation
{ TListRandomAStrings }
constructor TListRandomUStrings.Create(const AUStrings: TUnicodeStrings;
AOwner: Boolean);
begin
inherited Create(AUStrings.Count);
FUStrings := AUStrings;
FOwner := AOwner;
end;
destructor TListRandomUStrings.Destroy;
begin
if FOwner then
FreeAndNil(FUStrings);
inherited;
end;
function TListRandomUStrings.Next: UnicodeString;
var k: Integer;
begin
k := NextIndex();
if k<>-1 then
Result := FUStrings[k]
else
Result := FDefault
end;
procedure TListRandomUStrings.Update;
begin
Count := FUStrings.Count;
end;
end.