-
Notifications
You must be signed in to change notification settings - Fork 5
/
untIniSettings.pas
72 lines (52 loc) · 1.81 KB
/
untIniSettings.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
62
63
64
65
66
67
68
69
70
71
72
unit untIniSettings;
interface
uses IniFiles32, SysUtils, untVariables;
procedure LoadSettingsFromIni(fname: string);
procedure SaveSettingsToIni(fname: string);
function ReplaceGlobalKeywords(dataIn:string): string;
implementation
uses untMain;
function ReplaceGlobalKeywords(dataIn:string): string;
var
l: string;
begin
rf := [rfReplaceAll];
l := StringReplace(dataIn, '<temp_dir>', tempDir, rf);
l := StringReplace(l, '<app_dir>', currentDir + '\', rf);
result := l;
end;
//--------------------------------------------------------load settings from INI
procedure LoadSettingsFromIni(fname: string);
var myIni: TIniFile32;
sectionName: string;
begin
myIni := TIniFile32.Create(fname);
with myIni do
begin
sectionName := 'settings';
frmMain.memCharset.Text := readString(sectionName, 'charset', '');
frmMain.edtKeywordTrue.Text := readString(sectionName, 'keyword_true', '');
frmMain.edtURL.Text := readString(sectionName, 'url', '');
frmMain.edtParameters.Text := readString(sectionName, 'parameters', '');
frmMain.SetHTTPMethod(readString(sectionName, 'method', ''));
Free;
end;
end;
//--------------------------------------------------------save settings from INI
procedure SaveSettingsToIni(fname: string);
var myIni: TIniFile32;
sectionName: string;
begin
myIni := TIniFile32.Create(fname);
with myIni do
begin
sectionName := 'settings';
writeString(sectionName, 'charset', frmMain.memCharset.Text);
writeString(sectionName, 'keyword_true', frmMain.edtKeywordTrue.Text);
writeString(sectionName, 'url', frmMain.edtURL.Text);
writeString(sectionName, 'parameters', frmMain.edtParameters.Text);
writeString(sectionName, 'method', frmMain.GetHTTPMethod);
Free;
end;
end;
end.