-
Notifications
You must be signed in to change notification settings - Fork 2
/
FixDialogue.pas
108 lines (90 loc) · 3.24 KB
/
FixDialogue.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
Copies the RNAM of a dialogue into it's NAM1 - Response text
}
unit userscript;
var
ToFile: IInterface;
function findToFile(e: IInterface): boolean;
var
i, tpl: integer;
frm: TForm;
clb: TCheckListBox;
g: IInterface;
edid: widestring;
begin
Result := true;
if not Assigned(ToFile) then begin
frm := frmFileSelect;
try
frm.Caption := 'Select a plugin';
clb := TCheckListBox(frm.FindComponent('CheckListBox1'));
clb.Items.Add('<new file>');
for i := Pred(FileCount) downto 0 do begin
if (GetFileName(e) <> GetFileName(FileByIndex(i))) then begin
clb.Items.InsertObject(1, GetFileName(FileByIndex(i)), FileByIndex(i))
end else begin
Break;
end;
end;
if frm.ShowModal <> mrOk then begin
Result := false;
Exit;
end;
for i := 0 to Pred(clb.Items.Count) do begin
if clb.Checked[i] then begin
if i = 0 then ToFile := AddNewFile else
ToFile := ObjectToElement(clb.Items.Objects[i]);
Break;
end;
end;
finally
frm.Free;
end;
if not Assigned(ToFile) then begin
Result := false;
Exit;
end;
end;
end;
function Initialize: integer;
begin
Result := 0;
end;
function Process(e: IInterface): integer;
var
promptText, responseText: string;
responseArray, curResponse, newOverride: IInterface;
i: integer;
begin
Result := 0;
// only dial
if(Signature(e) <> 'INFO') then begin
exit;
end;
// comment this out if you don't want those messages
//AddMessage('Processing: ' + FullPath(e));
promptText := GetElementEditValues(e, 'RNAM');
if(promptText = '') then begin
exit;
end;
if(not assigned(ToFile)) then begin
if(not findToFile(e)) then begin
Result := 1;
exit;
end;
end;
AddRequiredElementMasters(e, ToFile, False);
newOverride := wbCopyElementToFile(e, ToFile, True, True);
responseArray := ElementByPath(newOverride, 'Responses');
for i:=0 to ElementCount(responseArray)-1 do begin
curResponse := ElementByIndex(responseArray, i);
responseText := GetElementEditValues(curResponse, 'NAM1 - Response Text');
if(responseText = '') then begin
AddMessage('Doing '+FullPath(curResponse));
//AddRequiredElementMasters(curResponse, ToFile, False);
//newOverride := wbCopyElementToFile(curResponse, ToFile, True, True);
SetElementEditValues(newOverride, 'NAM1 - Response Text', promptText);
end;
end;
end;
end.