-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path034.dat
34 lines (32 loc) · 987 Bytes
/
034.dat
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
function ExplodeStr(S, Delim: string; const List: Classes.TStrings;
const AllowEmpty: Boolean = True; const Trim: Boolean = False): Integer;
var
Item: string; // current delimited text
Remainder: string; // remaining un-consumed part of string
// ---------------------------------------------------------------------------
procedure AddItem;
begin
// Adds optionally trimmed item to list if required
if (Trim) then
Item := SysUtils.Trim(Item);
if (Item <> '') or AllowEmpty then
List.Add(Item);
end;
// ---------------------------------------------------------------------------
begin
// Clear the list
List.Clear;
// Check we have some entries in the string
if S <> '' then
begin
// Repeatedly split string until we have no more entries
while SplitStr(S, Delim, Item, Remainder) do
begin
AddItem;
S := Remainder;
end;
// Add any remaining item
AddItem;
end;
Result := List.Count;
end;