-
Notifications
You must be signed in to change notification settings - Fork 24
/
wDump.w
2719 lines (2159 loc) · 90.2 KB
/
wDump.w
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI
&ANALYZE-RESUME
&Scoped-define WINDOW-NAME wDump
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS wDump
/*------------------------------------------------------------------------
Name : wDump.w
Desc : Dump data
----------------------------------------------------------------------*/
/* This .W file was created with the Progress AppBuilder. */
/*----------------------------------------------------------------------*/
CREATE WIDGET-POOL.
{ DataDigger.i }
/* Parameters Definitions --- */
DEFINE INPUT PARAMETER pihBrowse AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER picSelectedFields AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER table FOR ttField.
/* Global Variable Definitions --- */
DEFINE VARIABLE gcDB AS CHARACTER NO-UNDO.
DEFINE VARIABLE gcTable AS CHARACTER NO-UNDO.
DEFINE VARIABLE gcLastFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE gcFileViewCmd AS CHARACTER NO-UNDO.
DEFINE VARIABLE glNoRecordsWarning AS LOGICAL NO-UNDO.
DEFINE VARIABLE gcSessionNumericFormat AS CHARACTER NO-UNDO.
DEFINE VARIABLE gcSessionDateFormat AS CHARACTER NO-UNDO.
DEFINE VARIABLE glAborted AS LOGICAL NO-UNDO.
DEFINE STREAM strDump.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
/* ******************** Preprocessor Definitions ******************** */
&Scoped-define PROCEDURE-TYPE Window
&Scoped-define DB-AWARE no
/* Name of designated FRAME-NAME and/or first browse and/or first query */
&Scoped-define FRAME-NAME DEFAULT-FRAME
/* Standard List Definitions */
&Scoped-Define ENABLED-OBJECTS RECT-2 RECT-3 RECT-4 ficFileName ~
btnChooseDumpFile cbDumpType cbCodePage tbUseCustomizedFormats cbSeparator ~
cbNumericFormat cbiRecordSelection cbDateFormat cbiFieldSelection btnDump ~
btnClose tbDumpReadyClose tbDumpReadyExplore tbDumpReadyView ~
tbDumpReadyClipboard ficMessageNow ficMessage
&Scoped-Define DISPLAYED-OBJECTS ficFileName cbDumpType cbCodePage ~
tbUseCustomizedFormats cbSeparator cbNumericFormat tbExportSchema ~
cbiRecordSelection cbDateFormat tbMinimalSchema cbiFieldSelection ~
tbDumpReadyClose tbDumpReadyExplore tbDumpReadyView tbDumpReadyClipboard ~
ficMessageNow ficMessage
/* Custom List Definitions */
/* List-1,List-2,List-3,List-4,List-5,List-6 */
/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME
/* ************************ Function Prototypes ********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD allFieldsInList wDump
FUNCTION allFieldsInList RETURNS LOGICAL
( INPUT pcFields AS CHARACTER
, INPUT pcList AS CHARACTER
) FORWARD.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD formatExcelString wDump
FUNCTION formatExcelString RETURNS CHARACTER (phField AS HANDLE, piIndex AS INTEGER) FORWARD.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getExcelCol wDump
FUNCTION getExcelCol RETURNS CHARACTER
( INPUT iColumnNr AS INTEGER ) FORWARD.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getFieldListFromIndexInformation wDump
FUNCTION getFieldListFromIndexInformation RETURNS CHARACTER
( INPUT picIndexInformation AS CHARACTER
) FORWARD.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getFieldValue wDump
FUNCTION getFieldValue RETURNS CHARACTER
( phField AS HANDLE
, piExtent AS INTEGER
) FORWARD.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* *********************** Control Definitions ********************** */
/* Define the widget handle for the window */
DEFINE VAR wDump AS WIDGET-HANDLE NO-UNDO.
/* Definitions of the field level widgets */
DEFINE BUTTON btnChooseDumpFile
LABEL "..."
SIZE-PIXELS 20 BY 21.
DEFINE BUTTON btnClose AUTO-END-KEY
LABEL "&Close"
SIZE-PIXELS 74 BY 24.
DEFINE BUTTON btnDump
LABEL "&Dump"
SIZE-PIXELS 74 BY 24 TOOLTIP "start the dump".
DEFINE BUTTON btnOpenLastDumpDir
LABEL "&Open"
SIZE-PIXELS 20 BY 23 TOOLTIP "open directory of last dump".
DEFINE BUTTON btnViewLastDump
LABEL "&View"
SIZE-PIXELS 20 BY 23 TOOLTIP "view the last exported file".
DEFINE VARIABLE cbCodePage AS CHARACTER INITIAL "0"
LABEL "Code &page"
VIEW-AS COMBO-BOX INNER-LINES 5
SIMPLE
SIZE-PIXELS 150 BY 23 TOOLTIP "the code page used for dumping" NO-UNDO.
DEFINE VARIABLE cbDateFormat AS CHARACTER FORMAT "X(256)":U
LABEL "D&ate Format"
VIEW-AS COMBO-BOX INNER-LINES 10
DROP-DOWN-LIST
SIZE-PIXELS 150 BY 21 TOOLTIP "the date format used for the dump" NO-UNDO.
DEFINE VARIABLE cbDumpType AS CHARACTER FORMAT "X(32)":U
LABEL "&Export as"
VIEW-AS COMBO-BOX INNER-LINES 8
LIST-ITEM-PAIRS "Comma Separated","CSV",
"Excel","XLSX",
"HTML","HTML",
"Progress dumpfile (*.d)","D",
"Text file","TXT",
"XML","XML",
"4GL code","P"
DROP-DOWN-LIST
SIZE-PIXELS 150 BY 21 TOOLTIP "type of format of the file" NO-UNDO.
DEFINE VARIABLE cbiFieldSelection AS INTEGER FORMAT "9":U INITIAL 0
LABEL "&Fields"
VIEW-AS COMBO-BOX INNER-LINES 3
LIST-ITEM-PAIRS "All",1,
"Selected",2
DROP-DOWN-LIST
SIZE-PIXELS 150 BY 21 TOOLTIP "the fieldset that will be exported" NO-UNDO.
DEFINE VARIABLE cbiRecordSelection AS INTEGER FORMAT "9":U INITIAL 0
LABEL "&Records"
VIEW-AS COMBO-BOX INNER-LINES 4
LIST-ITEM-PAIRS "Table",1,
"Browse",2,
"Selection",3
DROP-DOWN-LIST
SIZE-PIXELS 150 BY 21 TOOLTIP "the recordset that will be exported" NO-UNDO.
DEFINE VARIABLE cbNumericFormat AS CHARACTER FORMAT "X(256)":U INITIAL "0"
LABEL "&Numeric Format"
VIEW-AS COMBO-BOX INNER-LINES 6
DROP-DOWN-LIST
SIZE-PIXELS 150 BY 21 TOOLTIP "the numeric format used for dumping" NO-UNDO.
DEFINE VARIABLE cbSeparator AS INTEGER FORMAT "9":U INITIAL 1
LABEL "&Separator"
VIEW-AS COMBO-BOX INNER-LINES 4
LIST-ITEM-PAIRS "Comma",1,
"Pipe",2,
"Semicolon",3
DROP-DOWN-LIST
SIZE-PIXELS 150 BY 21 TOOLTIP "character used to separate fields in a record" NO-UNDO.
DEFINE VARIABLE ficFileName AS CHARACTER FORMAT "X(256)":U
LABEL "&Dumpfile"
VIEW-AS FILL-IN NATIVE
SIZE-PIXELS 570 BY 21 TOOLTIP "the name and path of the resulting dumpfile" NO-UNDO.
DEFINE VARIABLE ficMessage AS CHARACTER FORMAT "X(256)":U
VIEW-AS TEXT
SIZE-PIXELS 735 BY 13 NO-UNDO.
DEFINE VARIABLE ficMessageNow AS CHARACTER FORMAT "X(256)":U
VIEW-AS TEXT
SIZE-PIXELS 130 BY 13 NO-UNDO.
DEFINE RECTANGLE RECT-2
EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
SIZE-PIXELS 795 BY 145.
DEFINE RECTANGLE RECT-3
EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
SIZE-PIXELS 800 BY 65.
DEFINE RECTANGLE RECT-4
EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
SIZE-PIXELS 580 BY 40.
DEFINE VARIABLE tbDumpReadyClipboard AS LOGICAL INITIAL no
LABEL "Data to Clip&board"
VIEW-AS TOGGLE-BOX
SIZE-PIXELS 137 BY 17 NO-UNDO.
DEFINE VARIABLE tbDumpReadyClose AS LOGICAL INITIAL no
LABEL "C&lose window"
VIEW-AS TOGGLE-BOX
SIZE-PIXELS 115 BY 17 NO-UNDO.
DEFINE VARIABLE tbDumpReadyExplore AS LOGICAL INITIAL no
LABEL "E&xplore dump dir"
VIEW-AS TOGGLE-BOX
SIZE-PIXELS 121 BY 17 NO-UNDO.
DEFINE VARIABLE tbDumpReadyView AS LOGICAL INITIAL no
LABEL "&View dump file"
VIEW-AS TOGGLE-BOX
SIZE-PIXELS 113 BY 17 NO-UNDO.
DEFINE VARIABLE tbExportSchema AS LOGICAL INITIAL no
LABEL "Export &XML schema"
VIEW-AS TOGGLE-BOX
SIZE-PIXELS 205 BY 17 TOOLTIP "also export the schema to the XML file" NO-UNDO.
DEFINE VARIABLE tbMinimalSchema AS LOGICAL INITIAL no
LABEL "&Minimal Schema"
VIEW-AS TOGGLE-BOX
SIZE-PIXELS 205 BY 17 TOOLTIP "use a minimal schema export" NO-UNDO.
DEFINE VARIABLE tbUseCustomizedFormats AS LOGICAL INITIAL no
LABEL "&Use Customized Field Formats"
VIEW-AS TOGGLE-BOX
SIZE-PIXELS 205 BY 17 TOOLTIP "export with the customized field formats instead of dictionary formats" NO-UNDO.
DEFINE BUTTON btAbort
LABEL "Abort"
SIZE-PIXELS 75 BY 24 TOOLTIP "abort the dumping process".
DEFINE VARIABLE fcInfoLine AS CHARACTER FORMAT "X(256)":U
VIEW-AS TEXT
SIZE-PIXELS 165 BY 13 NO-UNDO.
DEFINE RECTANGLE rcBody
EDGE-PIXELS 2 GRAPHIC-EDGE
SIZE-PIXELS 50 BY 20
BGCOLOR 9 .
DEFINE RECTANGLE rcBorder
EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
SIZE-PIXELS 165 BY 20.
/* ************************ Frame Definitions *********************** */
DEFINE FRAME DEFAULT-FRAME
ficFileName AT Y 15 X 97 COLON-ALIGNED
btnChooseDumpFile AT Y 15 X 682
cbDumpType AT Y 45 X 97 COLON-ALIGNED
cbCodePage AT Y 45 X 384 COLON-ALIGNED
tbUseCustomizedFormats AT Y 66 X 576
cbSeparator AT Y 70 X 97 COLON-ALIGNED
cbNumericFormat AT Y 70 X 384 COLON-ALIGNED
tbExportSchema AT Y 85 X 576
cbiRecordSelection AT Y 95 X 97 COLON-ALIGNED
cbDateFormat AT Y 95 X 384 COLON-ALIGNED
tbMinimalSchema AT Y 104 X 576
cbiFieldSelection AT Y 120 X 97 COLON-ALIGNED
btnViewLastDump AT Y 200 X 750
btnOpenLastDumpDir AT Y 200 X 773
btnDump AT Y 265 X 649
btnClose AT Y 265 X 729
tbDumpReadyClose AT Y 270 X 15
tbDumpReadyExplore AT Y 270 X 145
tbDumpReadyView AT Y 270 X 282
tbDumpReadyClipboard AT Y 270 X 406
ficMessageNow AT Y 184 X 0 COLON-ALIGNED NO-LABEL
ficMessage AT Y 203 X 0 COLON-ALIGNED NO-LABEL
"Last dump" VIEW-AS TEXT
SIZE-PIXELS 87 BY 13 AT Y 163 X 13
"After the dump ..." VIEW-AS TEXT
SIZE-PIXELS 103 BY 13 AT Y 248 X 12
RECT-2 AT Y 5 X 10
RECT-3 AT Y 169 X 5
RECT-4 AT Y 254 X 5
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT X 0 Y 0
SIZE-PIXELS 810 BY 301
DEFAULT-BUTTON btnDump.
DEFINE FRAME infoFrame
btAbort AT Y 58 X 60
fcInfoLine AT Y 10 X 0 COLON-ALIGNED NO-LABEL
rcBorder AT Y 30 X 10
rcBody AT Y 29 X 10
WITH 1 DOWN KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT X 280 Y 84
SIZE-PIXELS 188 BY 103.
/* *********************** Procedure Settings ************************ */
&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
Type: Window
Allow: Basic,Browse,DB-Fields,Window,Query
Other Settings: COMPILE
*/
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS
/* ************************* Create Window ************************** */
&ANALYZE-SUSPEND _CREATE-WINDOW
IF SESSION:DISPLAY-TYPE = "GUI":U THEN
CREATE WINDOW wDump ASSIGN
HIDDEN = YES
TITLE = "Save as"
HEIGHT-P = 299
WIDTH-P = 810
MAX-HEIGHT-P = 608
MAX-WIDTH-P = 958
VIRTUAL-HEIGHT-P = 608
VIRTUAL-WIDTH-P = 958
MIN-BUTTON = no
MAX-BUTTON = no
RESIZE = no
SCROLL-BARS = no
STATUS-AREA = no
BGCOLOR = ?
FGCOLOR = ?
KEEP-FRAME-Z-ORDER = yes
THREE-D = yes
MESSAGE-AREA = no
SENSITIVE = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
/* END WINDOW DEFINITION */
&ANALYZE-RESUME
/* *********** Runtime Attributes and AppBuilder Settings *********** */
&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW wDump
VISIBLE,,RUN-PERSISTENT */
/* REPARENT FRAME */
ASSIGN FRAME infoFrame:FRAME = FRAME DEFAULT-FRAME:HANDLE.
/* SETTINGS FOR FRAME DEFAULT-FRAME
FRAME-NAME */
/* SETTINGS FOR BUTTON btnOpenLastDumpDir IN FRAME DEFAULT-FRAME
NO-ENABLE */
/* SETTINGS FOR BUTTON btnViewLastDump IN FRAME DEFAULT-FRAME
NO-ENABLE */
ASSIGN
ficMessage:READ-ONLY IN FRAME DEFAULT-FRAME = TRUE.
ASSIGN
ficMessageNow:READ-ONLY IN FRAME DEFAULT-FRAME = TRUE.
/* SETTINGS FOR TOGGLE-BOX tbExportSchema IN FRAME DEFAULT-FRAME
NO-ENABLE */
/* SETTINGS FOR TOGGLE-BOX tbMinimalSchema IN FRAME DEFAULT-FRAME
NO-ENABLE */
/* SETTINGS FOR FRAME infoFrame
*/
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wDump)
THEN wDump:HIDDEN = no.
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME
/* ************************ Control Triggers ************************ */
&Scoped-define SELF-NAME wDump
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wDump wDump
ON END-ERROR OF wDump /* Save as */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
/* This case occurs when the user presses the "Esc" key.
In a persistently run window, just ignore this. If we did not, the
application would exit. */
IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wDump wDump
ON LEAVE OF wDump /* Save as */
DO:
/* This event will close the window and terminate the procedure. */
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wDump wDump
ON WINDOW-CLOSE OF wDump /* Save as */
DO:
/* This event will close the window and terminate the procedure. */
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define FRAME-NAME infoFrame
&Scoped-define SELF-NAME btAbort
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btAbort wDump
ON CHOOSE OF btAbort IN FRAME infoFrame /* Abort */
DO:
glAborted = TRUE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define FRAME-NAME DEFAULT-FRAME
&Scoped-define SELF-NAME btnChooseDumpFile
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnChooseDumpFile wDump
ON CHOOSE OF btnChooseDumpFile IN FRAME DEFAULT-FRAME /* ... */
DO:
DEFINE VARIABLE lOkay AS LOGICAL NO-UNDO.
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
cFileName = ficFileName:screen-value.
SYSTEM-DIALOG GET-FILE cFilename
FILTERS "XML Dumpfile (*.xml)" "*.xml",
".d Dumpfile (*.d)" "*.d",
"Any File (*.*)" "*.*"
INITIAL-FILTER 1
ASK-OVERWRITE
USE-FILENAME
CREATE-TEST-FILE
DEFAULT-EXTENSION ".xml"
SAVE-AS
UPDATE lOkay.
IF NOT lOkay THEN
RETURN.
DO WITH FRAME {&frame-name}:
ficFileName = LC(cFileName).
DISPLAY ficFileName.
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnDump
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnDump wDump
ON CHOOSE OF btnDump IN FRAME DEFAULT-FRAME /* Dump */
OR GO OF FRAME {&frame-name}
DO:
DEFINE VARIABLE lContinue AS LOGICAL NO-UNDO.
RUN btnDumpChoose(OUTPUT lContinue).
IF NOT lContinue THEN RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnOpenLastDumpDir
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnOpenLastDumpDir wDump
ON CHOOSE OF btnOpenLastDumpDir IN FRAME DEFAULT-FRAME /* Open */
DO:
RUN btnOpenLastDumpDirChoose.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnViewLastDump
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnViewLastDump wDump
ON CHOOSE OF btnViewLastDump IN FRAME DEFAULT-FRAME /* View */
DO:
RUN btnViewLastDumpChoose.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbCodePage
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbCodePage wDump
ON VALUE-CHANGED OF cbCodePage IN FRAME DEFAULT-FRAME /* Code page */
DO:
RUN cbCodePageValueChanged.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbDateFormat
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbDateFormat wDump
ON VALUE-CHANGED OF cbDateFormat IN FRAME DEFAULT-FRAME /* Date Format */
DO:
RUN cbDateFormatValueChanged.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbDumpType
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbDumpType wDump
ON VALUE-CHANGED OF cbDumpType IN FRAME DEFAULT-FRAME /* Export as */
DO:
RUN cbDumpTypeValueChanged.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbiFieldSelection
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbiFieldSelection wDump
ON VALUE-CHANGED OF cbiFieldSelection IN FRAME DEFAULT-FRAME /* Fields */
DO:
RUN cbiFieldSelectionValueChanged.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbiRecordSelection
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbiRecordSelection wDump
ON VALUE-CHANGED OF cbiRecordSelection IN FRAME DEFAULT-FRAME /* Records */
DO:
RUN cbiRecordSelectionValueChanged.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbNumericFormat
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbNumericFormat wDump
ON VALUE-CHANGED OF cbNumericFormat IN FRAME DEFAULT-FRAME /* Numeric Format */
DO:
RUN cbNumericFormatValueChanged.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbSeparator
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbSeparator wDump
ON VALUE-CHANGED OF cbSeparator IN FRAME DEFAULT-FRAME /* Separator */
DO:
DO WITH FRAME {&FRAME-NAME}:
ASSIGN cbSeparator.
setRegistry("DumpAndLoad", "FieldSeparator", STRING(cbSeparator) ).
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME ficFileName
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ficFileName wDump
ON LEAVE OF ficFileName IN FRAME DEFAULT-FRAME /* Dumpfile */
DO:
ASSIGN ficFileName.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME tbDumpReadyClose
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tbDumpReadyClose wDump
ON VALUE-CHANGED OF tbDumpReadyClose IN FRAME DEFAULT-FRAME /* Close window */
, tbDumpReadyExplore, tbDumpReadyView, tbDumpReadyClipboard
DO:
DEFINE VARIABLE cDumpReadyAction AS CHARACTER NO-UNDO.
IF tbDumpReadyClose :CHECKED THEN cDumpReadyAction = cDumpReadyAction + ',Close'.
IF tbDumpReadyExplore :CHECKED THEN cDumpReadyAction = cDumpReadyAction + ',Explore'.
IF tbDumpReadyView :CHECKED THEN cDumpReadyAction = cDumpReadyAction + ',View'.
IF tbDumpReadyClipboard:CHECKED THEN cDumpReadyAction = cDumpReadyAction + ',Clipboard'.
cDumpReadyAction = REPLACE(cDumpReadyAction,",,",",").
cDumpReadyAction = TRIM(cDumpReadyAction,",").
IF cDumpReadyAction = "" THEN cDumpReadyAction = "Nothing".
setRegistry('DumpAndLoad','DumpReadyAction',cDumpReadyAction).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME tbExportSchema
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tbExportSchema wDump
ON VALUE-CHANGED OF tbExportSchema IN FRAME DEFAULT-FRAME /* Export XML schema */
DO:
RUN tbExportSchemaValueChanged.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME tbMinimalSchema
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tbMinimalSchema wDump
ON VALUE-CHANGED OF tbMinimalSchema IN FRAME DEFAULT-FRAME /* Minimal Schema */
DO:
RUN tbMinimalSchemaValueChanged.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME tbUseCustomizedFormats
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tbUseCustomizedFormats wDump
ON VALUE-CHANGED OF tbUseCustomizedFormats IN FRAME DEFAULT-FRAME /* Use Customized Field Formats */
DO:
RUN tbUseCustomizedFormatsValueChanged.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&UNDEFINE SELF-NAME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK wDump
/* *************************** Main Block *************************** */
/* Set CURRENT-WINDOW: this will parent dialog-boxes and frames. */
ASSIGN CURRENT-WINDOW = {&WINDOW-NAME}
THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.
/* The CLOSE event can be used from inside or outside the procedure to */
/* terminate it. */
ON CLOSE OF THIS-PROCEDURE
RUN disable_UI.
/* Best default for GUI applications is... */
PAUSE 0 BEFORE-HIDE.
/* Now enable the interface and wait for the exit condition. */
/* (NOTE: handle ERROR and END-KEY so cleanup code will always fire. */
MAIN-BLOCK:
DO ON ERROR UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
RUN initializeObject.
IF NOT THIS-PROCEDURE:PERSISTENT THEN
WAIT-FOR CLOSE OF THIS-PROCEDURE.
END.
/* Restore settings */
SESSION:DATE-FORMAT = gcSessionDateFormat.
SESSION:NUMERIC-FORMAT = gcSessionNumericFormat.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ********************** Internal Procedures *********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE btnDumpChoose wDump
PROCEDURE btnDumpChoose :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEFINE OUTPUT PARAMETER plContinue AS LOGICAL NO-UNDO.
DEFINE VARIABLE cAction AS CHARACTER NO-UNDO.
DEFINE VARIABLE iAction AS INTEGER NO-UNDO.
DEFINE VARIABLE cError AS CHARACTER NO-UNDO.
DO WITH FRAME {&frame-name}:
IF NOT isValidCodePage(cbCodePage:SCREEN-VALUE) THEN
DO:
MESSAGE cbCodePage:SCREEN-VALUE 'is not a valid code page' VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
RETURN.
END.
/* For Excel, we need a 12-something codepage */
IF cbDumpType:SCREEN-VALUE = "XLSX" THEN
DO:
/* Use 12* codepage for Excel */
IF cbCodePage:SCREEN-VALUE = ? AND SESSION:CPSTREAM BEGINS '12' THEN
cbCodePage:SCREEN-VALUE = SESSION:CPSTREAM.
/* ISO88591 can almost always be mapped to 1252 */
IF SESSION:CPSTREAM BEGINS 'ISO8859' THEN
cbCodePage:SCREEN-VALUE = '1252'.
/* Otherwise nag about it */
IF NOT cbCodePage:SCREEN-VALUE BEGINS '12' THEN
DO:
MESSAGE 'For Excel, use a Windows codepage like 1250,1251,1252 etc' SKIP
'Your current CPSTREAM codepage is' SESSION:CPSTREAM VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
RETURN.
END.
END.
RUN checkDir(INPUT ficFileName:SCREEN-VALUE, OUTPUT cError).
IF cError <> '' THEN
DO:
MESSAGE cError VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
RETURN.
END.
RUN dumpData
( INPUT pihBrowse /* phDdBrowse */
, INPUT cbDumpType:SCREEN-VALUE /* pcFormat */
, INPUT cbiRecordSelection:SCREEN-VALUE /* piRecordSelection */
, INPUT cbiFieldSelection:SCREEN-VALUE /* piRecordSelection */
, INPUT ficFileName:SCREEN-VALUE /* pcFile */
, INPUT cbCodePage:SCREEN-VALUE /* pcCodePage */
).
cAction = getRegistry('DumpAndLoad','DumpReadyAction').
DO iAction = 1 TO NUM-ENTRIES(cAction):
CASE ENTRY(iAction,cAction):
WHEN 'view' THEN APPLY 'choose' TO btnViewLastDump.
WHEN 'explore' THEN APPLY 'choose' TO btnOpenLastDumpDir.
WHEN 'clipboard' THEN RUN tbDumpReadyClipboard.
END CASE.
END.
/* Do the close as last action */
plContinue = TRUE.
IF CAN-DO(cAction,"Close") THEN APPLY "CLOSE" TO THIS-PROCEDURE.
END.
END PROCEDURE. /* btnDumpChoose */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE btnOpenLastDumpDirChoose wDump
PROCEDURE btnOpenLastDumpDirChoose :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEFINE VARIABLE cDumpDir AS CHARACTER NO-UNDO.
DO WITH FRAME {&frame-name}:
/* Strip filename, only keep path */
cDumpDir = getRegistry("DumpAndLoad", "DumpLastFileName").
IF cDumpDir = ? THEN RETURN.
ENTRY(NUM-ENTRIES(cDumpDir,'\'),cDumpDir,'\') = ''.
IF cDumpDir = "" THEN cDumpDir = ".". /* if blank go to DD dir */
FILE-INFO:FILE-NAME = cDumpDir.
IF FILE-INFO:FULL-PATHNAME <> ? THEN
OS-COMMAND NO-WAIT VALUE(SUBSTITUTE("explorer /n, /e, &1", FILE-INFO:FULL-PATHNAME)).
ELSE
MESSAGE SUBSTITUTE("Last used dir '&1' not found.", cDumpDir)
VIEW-AS ALERT-BOX INFORMATION BUTTONS OK TITLE "Invalid Dir" .
END.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE btnViewLastDumpChoose wDump
PROCEDURE btnViewLastDumpChoose :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEFINE VARIABLE cCmd AS CHARACTER NO-UNDO.
DEFINE VARIABLE cDumpType AS CHARACTER NO-UNDO.
cDumpType = getRegistry("DumpAndLoad", "DumpExportType" ).
cCmd = getRegistry("DumpAndLoad", SUBSTITUTE("DumpFileViewCmd_&1",cDumpType) ).
ASSIGN
cCmd = SUBSTITUTE(cCmd, gcLastFile)
cCmd = SUBSTITUTE('"&1"',cCmd)
.
PUBLISH "message" ( 50, SUBSTITUTE("DD FileViewCommand: &1",cCmd) ).
OS-COMMAND NO-WAIT VALUE(cCmd).
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE btnViewLastDumpEnable wDump
PROCEDURE btnViewLastDumpEnable :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DO WITH FRAME {&frame-name}:
gcLastFile = getRegistry("DumpAndLoad", "DumpLastFileName").
IF gcLastFile <> ? THEN
DO:
FILE-INFO:FILENAME = gcLastFile.
gcLastFile = FILE-INFO:FULL-PATHNAME.
END.
IF gcLastFile <> ? THEN
ENABLE btnViewLastDump btnOpenLastDumpDir.
ELSE
DISABLE btnViewLastDump btnOpenLastDumpDir.
END.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cbCodePageValueChanged wDump
PROCEDURE cbCodePageValueChanged :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DO WITH FRAME {&frame-name}:
ASSIGN cbCodePage.
setRegistry("DumpAndLoad", "DumpCodePage", cbCodePage ).
END.
END PROCEDURE. /* cbCodePageValueChanged */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cbDateFormatValueChanged wDump
PROCEDURE cbDateFormatValueChanged :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DO WITH FRAME {&frame-name}:
ASSIGN cbDateFormat.
setRegistry("DumpAndLoad", "DumpDateFormat", cbDateFormat ).
END.
END PROCEDURE. /* cbDateFormatValueChanged */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cbDumpTypeValueChanged wDump
PROCEDURE cbDumpTypeValueChanged :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DO WITH FRAME {&frame-name}:
ASSIGN cbDumpType.
/* Save dump type */
gcFileViewCmd = getRegistry("DumpAndLoad", SUBSTITUTE("DumpFileViewCmd_&1",cbDumpType) ).
IF gcFileViewCmd = ? THEN
DO:
gcFileViewCmd = getRegistry("DumpAndLoad", "DumpFileViewCmd").
setRegistry("DumpAndLoad", SUBSTITUTE("DumpFileViewCmd_&1",cbDumpType), gcFileViewCmd).
END. /* if gcFileViewCmd = ? then */
CASE cbDumpType:
WHEN "XML" THEN
DO:
ENABLE tbExportSchema.
DISABLE cbNumericFormat cbDateFormat.
cbNumericFormat = 'American'.
cbDateFormat = 'YMD'.
IF tbUseCustomizedFormats:SENSITIVE THEN
tbUseCustomizedFormats:CHECKED = TRUE.
END.
WHEN "P" THEN
DO:
DISABLE cbNumericFormat cbDateFormat tbExportSchema.
ASSIGN
cbNumericFormat = 'American'
cbDateFormat = 'MDY'.
END.
OTHERWISE
DO:
DISABLE tbExportSchema.
ENABLE cbNumericFormat cbDateFormat.
END.
END CASE.
/* For progress dump file and XML, use dictionary format by default
* For others, use customized
*/
IF cbDumpType = "XML"
OR cbDumpType = "D" THEN
DO:
/* But only if there has been changed something by the
* user, otherwise this is not relevant
*/
tbUseCustomizedFormats:SENSITIVE = FALSE.
tbUseCustomizedFormats:CHECKED = FALSE.
END.
ELSE
DO:
/* Find out whether the user has some customized fields */
IF CAN-FIND(FIRST ttField WHERE ttField.cFormat <> ttField.cFormatOrg) THEN
ASSIGN tbUseCustomizedFormats:SENSITIVE = TRUE
tbUseCustomizedFormats:CHECKED = TRUE.
ELSE
ASSIGN tbUseCustomizedFormats:SENSITIVE = FALSE
tbUseCustomizedFormats:CHECKED = FALSE.
END.
/* Separator only for csv */
cbSeparator:SENSITIVE = (cbDumpType = "CSV").
/* replace extension of filename */
IF ficFileName = '' THEN
RUN setDumpFileName.
IF NUM-ENTRIES(ficFileName,'.') > 1 THEN
ENTRY(NUM-ENTRIES(ficFileName,'.'),ficFileName,'.') = LOWER(cbDumpType).
ELSE
ficFileName = ficFileName + '.' + lower(cbDumpType).
DISPLAY ficFileName cbNumericFormat cbDateFormat.
END.
RUN tbExportSchemaValueChanged.