-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsettings.pas
61 lines (49 loc) · 1.05 KB
/
settings.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
60
61
unit Settings;
interface
uses
SysUtils, IniFiles;
var
LMinDepth, LMaxDepth: integer;
LBook: string;
implementation
const
CSection = 'settings';
var
LFileName: TFileName;
procedure ReadIniFile;
const
CDefaultMinDepth = 3;
CDefaultMaxDepth = 7;
CDefaultBook = 'gm2001.bin';
var
LFile: TIniFile;
begin
LFile := TIniFile.Create(LFileName);
try
LMinDepth := LFile.ReadInteger(CSection, 'mindepth', CDefaultMinDepth);
LMaxDepth := LFile.ReadInteger(CSection, 'maxdepth', CDefaultMaxDepth);
LBook := LFile.ReadString(CSection, 'book', CDefaultBook);
finally
LFile.Free;
end;
end;
procedure WriteIniFile;
var
LFile: TIniFile;
begin
LFile := TIniFile.Create(LFileName);
try
LFile.WriteInteger(CSection, 'mindepth', LMinDepth);
LFile.WriteInteger(CSection, 'maxdepth', LMaxDepth);
LFile.WriteString(CSection, 'book', LBook);
finally
LFile.Free;
end;
end;
initialization
LFileName := ChangeFileExt(ParamStr(0), '.ini');
ReadIniFile;
finalization
if not FileExists(LFileName) then
WriteIniFile;
end.