5 function config_open(FileName
: string): Boolean;
6 function config_read_int(param
: string; def
: Integer): Integer;
7 function config_read_str(param
: string; def
: string): string;
8 function config_read_bool(param
: string; def
: Boolean): Boolean;
9 procedure config_close();
16 cfg_data
: array of ShortString = nil;
18 function tostr(i
: Integer): string;
23 function toint(s
: string; var i
: Integer): Boolean;
32 function readparam(param
: string; var s
: string): Boolean;
34 a
, b
, len
, d_len
: Integer;
38 if cfg_data
= nil then Exit
;
40 d_len
:= Length(cfg_data
);
42 for a
:= 0 to d_len
do
44 len
:= Length(cfg_data
[a
]);
48 if cfg_data
[a
][b
] = '=' then
49 if Copy(cfg_data
[a
], 1, b
-1) = param
then
51 s
:= Copy(cfg_data
[a
], b
+1, len
);
58 function config_open(FileName
: string): Boolean;
62 len
, d_len
, line
: Integer;
66 if cfg_data
<> nil then config_close();
68 AssignFile(f
, FileName
);
74 if IOResult
<> 0 then Exit
;
77 SetLength(cfg_data
, d_len
);
85 if len
< 3 then Continue
;
86 if str
[1] = ';' then Continue
;
91 SetLength(cfg_data
, d_len
);
94 cfg_data
[line
] := str
;
103 function config_read_int(param
: string; def
: Integer): Integer;
109 if not readparam(param
, s
) then Exit
;
111 if not toint(s
, Result
) then Result
:= def
;
114 function config_read_str(param
: string; def
: string): string;
120 if not readparam(param
, s
) then Exit
;
125 function config_read_bool(param
: string; def
: Boolean): Boolean;
131 if not readparam(param
, s
) then Exit
;
136 procedure config_close();
138 if cfg_data
<> nil then cfg_data
:= nil;