Rev 750 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 750 | Rev 995 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | unit VTSFUNCS; |
1 | unit VTSFUNCS; |
2 | 2 | ||
3 | (************************************************) |
3 | (************************************************) |
4 | (* VTSFUNCS.PAS *) |
4 | (* VTSFUNCS.PAS *) |
5 | (* Author: Daniel Marschall *) |
5 | (* Author: Daniel Marschall *) |
6 | (* Revision: 2022-02-22 *) |
6 | (* Revision: 2022-10-11 *) |
7 | (* License: Apache 2.0 *) |
7 | (* License: Apache 2.0 *) |
8 | (* This file contains: *) |
8 | (* This file contains: *) |
9 | (* - Various functions *) |
9 | (* - Various functions *) |
10 | (************************************************) |
10 | (************************************************) |
11 | 11 | ||
Line 30... | Line 30... | ||
30 | function FileExists(filename: string): boolean; |
30 | function FileExists(filename: string): boolean; |
31 | 31 | ||
32 | function StripLeadingZeros(s: string): string; |
32 | function StripLeadingZeros(s: string): string; |
33 | function IsPositiveIntegerOrZero(s: string): boolean; |
33 | function IsPositiveIntegerOrZero(s: string): boolean; |
34 | function IsBase36String(s: string): boolean; |
34 | function IsBase36String(s: string): boolean; |
- | 35 | function TryStrToInt(s: string; var i: LongInt): boolean; |
|
35 | function StrToInt(s: string): Integer; |
36 | function StrToInt(s: string): LongInt; |
36 | function IntToStr(Value: Integer): string; |
37 | function IntToStr(Value: LongInt): string; |
37 | 38 | ||
38 | function StringReplace(s, search, replace: string): string; |
39 | function StringReplace(s, search, replace: string): string; |
39 | 40 | ||
40 | function LastCharPos(const S: string; const Chr: char): integer; |
41 | function LastCharPos(const S: string; const Chr: char): integer; |
41 | function LowerCase(s: string): string; |
42 | function LowerCase(s: string): string; |
Line 249... | Line 250... | ||
249 | end; |
250 | end; |
250 | 251 | ||
251 | IsBase36String := true; |
252 | IsBase36String := true; |
252 | end; |
253 | end; |
253 | 254 | ||
- | 255 | function TryStrToInt(s: string; var i: LongInt): boolean; |
|
- | 256 | begin |
|
- | 257 | if IsPositiveIntegerOrZero(s) then |
|
- | 258 | begin |
|
- | 259 | TryStrToInt := true; |
|
- | 260 | i := StrToInt(s); |
|
- | 261 | end |
|
- | 262 | else |
|
- | 263 | begin |
|
- | 264 | TryStrToInt := false; |
|
- | 265 | end; |
|
- | 266 | end; |
|
- | 267 | ||
254 | function StrToInt(s: string): Integer; |
268 | function StrToInt(s: string): LongInt; |
255 | var |
269 | var |
256 | i, Error: Integer; |
270 | i, Error: Integer; |
257 | begin |
271 | begin |
258 | Val(s, i, Error); |
272 | Val(s, i, Error); |
259 | StrToInt := i; |
273 | StrToInt := i; |
260 | end; |
274 | end; |
261 | 275 | ||
262 | function IntToStr(Value: Integer): string; |
276 | function IntToStr(Value: LongInt): string; |
263 | var |
277 | var |
264 | s: string; |
278 | s: string; |
265 | begin |
279 | begin |
266 | Str(Value, s); |
280 | Str(Value, s); |
267 | IntToStr := s; |
281 | IntToStr := s; |