-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathReplace text in EDID and FULL actually good.pas
58 lines (45 loc) · 1.5 KB
/
Replace text in EDID and FULL actually good.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
{
Search and replace for the EDID and FULL of the selected forms.
You will be asked for the search and replacement strings.
}
unit UserScript;
var
ReplaceCount: integer;
StrSearch :string;
StrReplace: string;
function Initialize: integer;
begin
ReplaceCount := 0;
if(not InputQuery('Replace Name Parts', 'Input Search String', StrSearch)) then begin
Result := 1;
exit;
end;
if(not InputQuery('Replace Name Parts', 'Input Replace String', StrReplace)) then begin
Result := 1;
exit;
end;
Result := 0;
end;
procedure SearchAndReplace(e: IInterface; s1, s2: string);
var
s: string;
begin
if not Assigned(e) then Exit;
// remove rfIgnoreCase to be case sensitive
s := StringReplace(GetEditValue(e), s1, s2, [rfReplaceAll, rfIgnoreCase]);
if not SameText(s, GetEditValue(e)) then begin
Inc(ReplaceCount);
AddMessage('Replacing in ' + FullPath(e));
SetEditValue(e, s);
end;
end;
function Process(e: IInterface): integer;
begin
SearchAndReplace(ElementBySignature(e, 'EDID'), StrSearch, StrReplace);
SearchAndReplace(ElementBySignature(e, 'FULL'), StrSearch, StrReplace);
end;
function Finalize: integer;
begin
AddMessage(Format('Replaced %d occurences.', [ReplaceCount]));
end;
end.