-
Notifications
You must be signed in to change notification settings - Fork 23
/
convertSettings.p
406 lines (303 loc) · 13.4 KB
/
convertSettings.p
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
/* convertSettings.p
*
* One-time conversions for new versions of DataDigger
*/
DEFINE INPUT PARAMETER piOldVersion AS INTEGER NO-UNDO.
{DataDigger.i}
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
/* ******************** Preprocessor Definitions ******************** */
&Scoped-define PROCEDURE-TYPE Procedure
&Scoped-define DB-AWARE no
/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME
/* *********************** Procedure Settings ************************ */
&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
Type: Procedure
Allow:
Frames: 0
Add Fields to: Neither
Other Settings: CODE-ONLY COMPILE
*/
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS
/* ************************* Create Window ************************** */
&ANALYZE-SUSPEND _CREATE-WINDOW
/* DESIGN Window definition (used by the UIB)
CREATE WINDOW Procedure ASSIGN
HEIGHT = 10.48
WIDTH = 41.6.
/* END WINDOW DEFINITION */
*/
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
/* *************************** Main Block *************************** */
SESSION:SET-WAIT-STATE("general").
RUN VALUE(SUBSTITUTE('ConvertFrom-&1', piOldVersion)) NO-ERROR.
RUN flushRegistry.
SESSION:SET-WAIT-STATE("").
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ********************** Internal Procedures *********************** */
&IF DEFINED(EXCLUDE-convertFrom-19) = 0 &THEN
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE convertFrom-19 Procedure
PROCEDURE convertFrom-19 :
/* v19 -> 20
*/
DEFINE BUFFER bfConfig FOR ttConfig.
/* Obsolete files */
OS-DELETE VALUE(SEARCH("getNewVersion.p")).
OS-DELETE VALUE(SEARCH("getNewVersion.r")).
OS-DELETE VALUE(SEARCH("frLoadMapping.w")).
OS-DELETE VALUE(SEARCH("frLoadMapping.r")).
OS-DELETE VALUE(SEARCH("DataDigger.chm")).
OS-DELETE VALUE(SEARCH("image/default_ReleaseNotes.gif")).
OS-DELETE VALUE(SEARCH("image/default_FilterCombo.gif")).
OS-DELETE VALUE(SEARCH("image/default_FilterComboRed.gif")).
OS-DELETE VALUE(SEARCH("image/default_Star.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tables.gif")).
OS-DELETE VALUE(SEARCH("image/default_PrevQuery.gif")).
OS-DELETE VALUE(SEARCH("image/default_NextQuery.gif")).
OS-DELETE VALUE(SEARCH("image/default_ViewAsList.gif")).
OS-DELETE VALUE(SEARCH("image/default_Pinned.gif")).
OS-DELETE VALUE(SEARCH("image/default_Unpinned.gif")).
OS-DELETE VALUE(SEARCH("image/default_Undock.gif")).
OS-DELETE VALUE(SEARCH("image/default_Dock.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_Favorites_Active.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_Favorites_Inactive.gif")).
/* Erase widths of table browse */
setRegistry('DataDigger','ColumnWidth:cTableName',?).
setRegistry('DataDigger','ColumnWidth:cDatabase',?).
setRegistry('DataDigger','ColumnWidth:iNumQueries',?).
/* Setting for last active page not used anymore */
setRegistry("DataDigger", "ActivePage",?).
/* Remove last used table from settings */
FOR EACH bfConfig WHERE bfConfig.cSection BEGINS 'DB:' BREAK BY bfConfig.cSection:
IF FIRST-OF(bfConfig.cSection) THEN setRegistry(bfConfig.cSection,'table',?).
END.
/* Updates (are in the general .ini file */
USE 'DataDigger.ini' NO-ERROR.
IF NOT ERROR-STATUS:ERROR THEN
DO:
PUT-KEY-VALUE SECTION "DataDigger:Update" KEY "UpdateCheck" VALUE ? NO-ERROR.
PUT-KEY-VALUE SECTION "DataDigger:Update" KEY "UpdateUrl" VALUE ? NO-ERROR.
PUT-KEY-VALUE SECTION "DataDigger:Update" KEY "UpdateChannel" VALUE ? NO-ERROR.
PUT-KEY-VALUE SECTION "DataDigger:Update" KEY "UpdateLastCheck" VALUE ? NO-ERROR.
PUT-KEY-VALUE SECTION "DataDigger:Update" KEY "" VALUE ? NO-ERROR.
END.
USE "".
END PROCEDURE. /* 19 */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ENDIF
&IF DEFINED(EXCLUDE-convertFrom-20) = 0 &THEN
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE convertFrom-20 Procedure
PROCEDURE convertFrom-20 :
/* v20 -> 21
*/
OS-DELETE VALUE(SEARCH("wEdit.wrx")).
END PROCEDURE. /* 20 */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ENDIF
&IF DEFINED(EXCLUDE-convertFrom-21) = 0 &THEN
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE convertFrom-21 Procedure
PROCEDURE convertFrom-21 :
/* v21 -> 22
*/
/* No conversions needed */
END PROCEDURE. /* 21 */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ENDIF
&IF DEFINED(EXCLUDE-convertFrom-22) = 0 &THEN
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE convertFrom-22 Procedure
PROCEDURE convertFrom-22 :
/* v22 -> 23
*/
OS-DELETE VALUE(SEARCH("dAbout.w")).
OS-DELETE VALUE(SEARCH("dAbout.r")).
OS-DELETE VALUE(SEARCH("image/default_Tab_About_Active.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_About_Inactive.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_Changes_Active.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_Changes_Inactive.gif")).
END PROCEDURE. /* 22 */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ENDIF
&IF DEFINED(EXCLUDE-convertFrom-23) = 0 &THEN
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE convertFrom-23 Procedure
PROCEDURE convertFrom-23 :
/* v23 -> 24
*/
DEFINE VARIABLE cValue AS CHARACTER NO-UNDO.
DEFINE BUFFER bfConfig FOR ttConfig.
/* Settings removed */
setRegistry("DataDigger", "AddDataColumnForRecid", ?).
setRegistry("DataDigger", "AddDataColumnForRowid", ?).
setRegistry("DataDigger:Cache","Settings",?).
setRegistry("DataDigger:Colors", "QueryCounter:FG", ?).
setRegistry("DataDigger:Colors", "QueryInfo:FG", ?).
/* DumpDf settings now in their own section */
setRegistry("DataDigger", "DumpDF:dir" , ?).
setRegistry("DataDigger", "DumpDF:open", ?).
/* Answer to confirm delete should not be saved when NO or CANCEL */
setRegistry("DataDigger:Help", "ConfirmDelete:hidden", ?).
/* Table browse is now slightly wider, so erase old column widths */
setRegistry("DataDigger", "ColumnWidth:cTableName" , ?).
setRegistry("DataDigger", "ColumnWidth:cDatabase" , ?).
setRegistry("DataDigger", "ColumnWidth:iNumQueries", ?).
/* dHint.w is not used */
OS-DELETE VALUE(SEARCH("dHint.w")).
OS-DELETE VALUE(SEARCH("dHint.r")).
/* A typo in previous versions prevented these from deletion */
/* DD19 */
OS-DELETE VALUE(SEARCH("getNewVersion.p")).
OS-DELETE VALUE(SEARCH("getNewVersion.r")).
OS-DELETE VALUE(SEARCH("frLoadMapping.w")).
OS-DELETE VALUE(SEARCH("frLoadMapping.r")).
OS-DELETE VALUE(SEARCH("DataDigger.chm")).
OS-DELETE VALUE(SEARCH("image/default_ReleaseNotes.gif")).
OS-DELETE VALUE(SEARCH("image/default_FilterCombo.gif")).
OS-DELETE VALUE(SEARCH("image/default_FilterComboRed.gif")).
OS-DELETE VALUE(SEARCH("image/default_Star.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tables.gif")).
OS-DELETE VALUE(SEARCH("image/default_PrevQuery.gif")).
OS-DELETE VALUE(SEARCH("image/default_NextQuery.gif")).
OS-DELETE VALUE(SEARCH("image/default_ViewAsList.gif")).
OS-DELETE VALUE(SEARCH("image/default_Pinned.gif")).
OS-DELETE VALUE(SEARCH("image/default_Unpinned.gif")).
OS-DELETE VALUE(SEARCH("image/default_Undock.gif")).
OS-DELETE VALUE(SEARCH("image/default_Dock.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_Favorites_Active.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_Favorites_Inactive.gif")).
/* DD20 */
OS-DELETE VALUE(SEARCH("wEdit.wrx")).
/* DD22 */
OS-DELETE VALUE(SEARCH("dAbout.w")).
OS-DELETE VALUE(SEARCH("dAbout.r")).
OS-DELETE VALUE(SEARCH("image/default_Tab_About_Active.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_About_Inactive.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_Changes_Active.gif")).
OS-DELETE VALUE(SEARCH("image/default_Tab_Changes_Inactive.gif")).
/* Obsolete stuff */
OS-DELETE VALUE(SEARCH("image/default_ViewAsEditor.gif.jpg")). /* actually still from DD19 */
OS-DELETE VALUE(SEARCH("DataDiggerAbout.txt")).
OS-DELETE VALUE(SEARCH("wAbout.wrx")).
OS-DELETE VALUE(SEARCH("dChooseFont.w")). /* replaced with adecomm/_chsfont.p */
OS-DELETE VALUE(SEARCH("dChooseColor.w")). /* replaced with adecomm/_chscolr.p */
OS-DELETE VALUE(SEARCH("image/default_AboutTitle.gif")).
OS-DELETE VALUE(SEARCH("image/default_AboutTitle2.gif")).
OS-DELETE VALUE(SEARCH("image/default_AboutTitle3.gif")).
OS-DELETE VALUE(SEARCH("image/default_Paddle.gif")).
OS-DELETE VALUE(SEARCH("image/default_Download.gif")).
OS-DELETE VALUE(SEARCH("image/default_Download_ins.gif")).
OS-DELETE VALUE(SEARCH("image/default_Upload.gif")).
OS-DELETE VALUE(SEARCH("image/default_ResizeHor.gif")).
OS-DELETE VALUE(SEARCH("image/default_Ok.gif")).
OS-DELETE VALUE(SEARCH("image/default_Back.gif")).
OS-DELETE VALUE(SEARCH("image/default_Compare.gif")).
OS-DELETE VALUE(SEARCH("image/default_DataDigger16x16.gif")).
OS-DELETE VALUE(SEARCH("image/default_Forward.gif")).
/* Setting '<PROGDIR>' renamed to '<WORKDIR>' */
cValue = getRegistry("DataDigger:Backup", "BackupDir").
setRegistry("DataDigger:Backup", "BackupDir", REPLACE(cValue,'<PROGDIR>', '<WORKDIR>')).
cValue = getRegistry("DataDigger:Backup", "BackupFileTemplate").
setRegistry("DataDigger:Backup", "BackupFileTemplate", REPLACE(cValue,'<PROGDIR>', '<WORKDIR>')).
cValue = getRegistry("DumpAndLoad", "DumpDir").
setRegistry("DumpAndLoad", "DumpDir", REPLACE(cValue,'<PROGDIR>', '<WORKDIR>')).
cValue = getRegistry("DumpAndLoad", "DumpFileTemplate").
setRegistry("DumpAndLoad", "DumpFileTemplate", REPLACE(cValue,'<PROGDIR>', '<WORKDIR>')).
/* Remove usage info, except for numUsed */
RUN getRegistryTable(OUTPUT TABLE bfConfig).
FOR EACH bfConfig WHERE bfConfig.cSection = "DataDigger:Hints":
IF NOT bfConfig.cSetting MATCHES '*' THEN
setRegistry(bfConfig.cSection,bfConfig.cSetting,?).
END.
/* Move old favourites to group 'myFavourites' */
FOR EACH bfConfig WHERE bfConfig.cSection BEGINS 'DB:'
AND bfConfig.cSetting MATCHES '*:favourite':
RUN setFavourite(ENTRY(2,bfConfig.cSection,':'), ENTRY(1,bfConfig.cSetting,':'), 'myFavourites', TRUE).
setRegistry(bfConfig.cSection,bfConfig.cSetting,?).
END.
EMPTY TEMP-TABLE bfConfig.
/* Old setting got re-created due to bug in DD23 */
setRegistry("DumpAndLoad", "DumpFileDir", ?).
END PROCEDURE. /* 23 */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ENDIF
&IF DEFINED(EXCLUDE-convertFrom-24) = 0 &THEN
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE convertFrom-24 Procedure
PROCEDURE convertFrom-24 :
/* v24 -> 25
*/
DEFINE BUFFER bfConfig FOR ttConfig.
DEFINE BUFFER btFavGroup FOR ttFavGroup.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE cTableName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cGroupName AS CHARACTER NO-UNDO.
/* Get all settings */
RUN getRegistryTable(OUTPUT TABLE bfConfig).
/* Convert usage info */
FOR EACH bfConfig WHERE bfConfig.cSection = "DataDigger:Usage":
IF NOT bfConfig.cSetting MATCHES '*' THEN
DO:
setRegistry("DataDigger:Hints", bfConfig.cSetting, "yes").
setRegistry(bfConfig.cSection, bfConfig.cSetting,?).
END.
END.
/* Convert favourites */
EMPTY TEMP-TABLE ttFavGroup.
FOR EACH bfConfig WHERE bfConfig.cSetting MATCHES '*:Favourites*':
cTableName = ENTRY(1,bfConfig.cSetting,':').
/* Customer:Favourites=myFavourites,Cust-stuff */
DO i = 1 TO NUM-ENTRIES(bfConfig.cValue):
cGroupName = ENTRY(i,bfConfig.cValue).
FIND btFavGroup WHERE btFavGroup.cGroup = cGroupName NO-ERROR.
IF NOT AVAILABLE btFavGroup THEN CREATE btFavGroup.
ASSIGN btFavGroup.cGroup = cGroupName.
IF LOOKUP(cTableName, btFavGroup.cTables) = 0 THEN
ASSIGN btFavGroup.cTables = TRIM(SUBSTITUTE('&1,&2', btFavGroup.cTables, cTableName),',').
END.
setRegistry(bfConfig.cSection, bfConfig.cSetting, ?). /* remove old setting */
END.
/* [DataDigger:Favourites]
* myFavourites=Customer,Order-Line,Order,Salesrep
* Cust-stuff=Customer,State
*/
FOR EACH btFavGroup:
setRegistry('DataDigger:Favourites', btFavGroup.cGroup, btFavGroup.cTables).
END.
/* Obsolete files */
OS-DELETE VALUE(SEARCH("dEditGroup.wrx")).
END PROCEDURE. /* 24 */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ENDIF
&IF DEFINED(EXCLUDE-convertFrom-25) = 0 &THEN
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE convertFrom-25 Procedure
PROCEDURE convertFrom-25 :
/* v25 -> 26
*/
DEFINE BUFFER bfConfig FOR ttConfig.
/* Query editor is now default not expanded on startup */
setRegistry("DataDigger", "QueryEditorState", ?).
/* Change of query separator */
RUN getRegistryTable(OUTPUT TABLE bfConfig).
FOR EACH bfConfig
WHERE bfConfig.cSection BEGINS "DB:"
AND bfConfig.cSetting MATCHES "*:query:*":
setRegistry( bfConfig.cSection
, bfConfig.cSetting
, REPLACE( bfConfig.cValue, CHR(1, SESSION:CPINTERNAL, "UTF-8")
, CHR(2, SESSION:CPINTERNAL, "UTF-8") ) ).
END.
END PROCEDURE. /* 25 */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ENDIF