Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit e097ab1

Browse files
committed
Break out utility functions
1 parent e6376ec commit e097ab1

File tree

2 files changed

+61
-45
lines changed

2 files changed

+61
-45
lines changed

ElixirWeb.iss

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -102,51 +102,7 @@ var
102102
103103
_int: Integer;
104104
105-
function SplitStringRec(Str: String; Delim: String; StrList: TStringList): TStringList;
106-
var
107-
StrHead: String;
108-
StrTail: String;
109-
DelimPos: Integer;
110-
begin
111-
DelimPos := Pos(Delim, Str);
112-
if (DelimPos = 0) then begin
113-
StrList.Add(Str);
114-
Result := StrList;
115-
end else begin
116-
StrHead := Str;
117-
StrTail := Str;
118-
119-
Delete(StrHead, DelimPos, Length(StrTail));
120-
Delete(StrTail, 1, DelimPos);
121-
122-
StrList.Add(StrHead);
123-
Result := SplitStringRec(StrTail, Delim, StrList);
124-
end;
125-
end;
126-
127-
function SplitString(Str: String; Delim: String): TStringList;
128-
begin
129-
Result := SplitStringRec(Str, Delim, TStringList.Create);
130-
end;
131-
132-
function GetURLFilePartRec(URL: String): String;
133-
var
134-
SlashPos: Integer;
135-
begin
136-
SlashPos := Pos('/', URL);
137-
if SlashPos = 0 then begin
138-
Result := URL;
139-
end else begin;
140-
Delete(URL, 1, SlashPos);
141-
Result := GetURLFilePartRec(URL);
142-
end;
143-
end;
144-
145-
function GetURLFilePart(URL: String): String;
146-
begin
147-
Delete(URL, 1, Pos('://', URL) + 2);
148-
Result := GetURLFilePartRec(URL);
149-
end;
105+
#include "src\util.iss"
150106
151107
function GetElixirCSVFilePath: String;
152108
begin

src/util.iss

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// util.iss - Useful helper functions
2+
// Copyright 2014 Chris Hyndman
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
function SplitStringRec(Str: String; Delim: String; StrList: TStringList): TStringList;
17+
var
18+
StrHead: String;
19+
StrTail: String;
20+
DelimPos: Integer;
21+
begin
22+
DelimPos := Pos(Delim, Str);
23+
if (DelimPos = 0) then begin
24+
StrList.Add(Str);
25+
Result := StrList;
26+
end else begin
27+
StrHead := Str;
28+
StrTail := Str;
29+
30+
Delete(StrHead, DelimPos, Length(StrTail));
31+
Delete(StrTail, 1, DelimPos);
32+
33+
StrList.Add(StrHead);
34+
Result := SplitStringRec(StrTail, Delim, StrList);
35+
end;
36+
end;
37+
38+
function SplitString(Str: String; Delim: String): TStringList;
39+
begin
40+
Result := SplitStringRec(Str, Delim, TStringList.Create);
41+
end;
42+
43+
function GetURLFilePartRec(URL: String): String;
44+
var
45+
SlashPos: Integer;
46+
begin
47+
SlashPos := Pos('/', URL);
48+
if SlashPos = 0 then begin
49+
Result := URL;
50+
end else begin;
51+
Delete(URL, 1, SlashPos);
52+
Result := GetURLFilePartRec(URL);
53+
end;
54+
end;
55+
56+
function GetURLFilePart(URL: String): String;
57+
begin
58+
Delete(URL, 1, Pos('://', URL) + 2);
59+
Result := GetURLFilePartRec(URL);
60+
end;

0 commit comments

Comments
 (0)