1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS V-table-Win
8 /*------------------------------------------------------------------------
12 Description
: from VIEWER.W
- Template for SmartViewer Objects
20 ------------------------------------------------------------------------*/
21 /* This .W file was created with the Progress UIB.
*/
22 /*----------------------------------------------------------------------*/
24 /* Create an unnamed pool to store all the widgets created
25 by this procedure. This is a good default which assures
26 that this procedure's triggers and internal procedures
27 will execute in this procedure's storage
, and that proper
28 cleanup will occur on deletion of the procedure.
*/
32 /* *************************** Definitions
************************** */
34 /* Parameters Definitions
--- */
36 /* Local Variable Definitions
--- */
38 &SCOPED-DEFINE REPORT-ID "Contact Export"
40 DEF VAR cty-list
AS CHAR NO-UNDO.
41 DEF VAR pty-list
AS CHAR NO-UNDO.
43 /* _UIB-CODE-BLOCK-END
*/
47 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
49 /* ******************** Preprocessor Definitions
******************** */
51 &Scoped-define PROCEDURE-TYPE SmartViewer
53 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
55 /* Name of first Frame and
/or Browse and
/or first Query
*/
56 &Scoped-define FRAME-NAME F-Main
59 &Scoped-define EXTERNAL-TABLES RP
60 &Scoped-define FIRST-EXTERNAL-TABLE RP
63 /* Need to scope the external tables to this procedure
*/
64 DEFINE QUERY external_tables
FOR RP.
65 /* Standard List Definitions
*/
66 &Scoped-Define ENABLED-FIELDS RP.Char1 RP.Char6 RP.Log5 RP.Log4 RP.Char5
67 &Scoped-define FIELD-PAIRS~
68 ~
{&FP1}Char5 ~{&FP2}Char5 ~{&FP3}
69 &Scoped-define ENABLED-TABLES RP
70 &Scoped-define FIRST-ENABLED-TABLE RP
71 &Scoped-Define ENABLED-OBJECTS RECT-28 cmb_PostalType-1 cmb_PostalType-2 ~
72 cmb_PostalType-3 btn_browse btn_export btn_cancel
73 &Scoped-Define DISPLAYED-FIELDS RP.Char1 RP.Char6 RP.Log5 RP.Log4 RP.Char5
74 &Scoped-Define DISPLAYED-OBJECTS cmb_PostalType-1 cmb_PostalType-2 ~
77 /* Custom List Definitions
*/
78 /* ADM-CREATE-FIELDS
,ADM-ASSIGN-FIELDS
,List-3
,List-4
,List-5
,List-6
*/
80 /* _UIB-PREPROCESSOR-BLOCK-END
*/
85 /* *********************** Control Definitions
********************** */
88 /* Definitions of the field level widgets
*/
89 DEFINE BUTTON btn_browse
94 DEFINE BUTTON btn_cancel
99 DEFINE BUTTON btn_export
104 DEFINE VARIABLE cmb_PostalType-1
AS CHARACTER FORMAT "X(256)":U
106 VIEW-AS COMBO-BOX INNER-LINES 10
108 SIZE 30.29 BY 1 NO-UNDO.
110 DEFINE VARIABLE cmb_PostalType-2
AS CHARACTER FORMAT "X(256)":U
112 VIEW-AS COMBO-BOX INNER-LINES 10
114 SIZE 30.29 BY 1 NO-UNDO.
116 DEFINE VARIABLE cmb_PostalType-3
AS CHARACTER FORMAT "X(256)":U
118 VIEW-AS COMBO-BOX INNER-LINES 10
120 SIZE 30.29 BY 1 NO-UNDO.
122 DEFINE RECTANGLE RECT-28
123 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
127 /* ************************ Frame Definitions
*********************** */
130 RP.Char1
AT ROW 2.5 COL 3.29 HELP
132 VIEW-AS SELECTION-LIST MULTIPLE SCROLLBAR-VERTICAL
134 RP.Char6
AT ROW 2.9 COL 45.29 HELP
136 VIEW-AS RADIO-SET VERTICAL
138 "Original Style", "Standard":U
,
139 "For sending to another system", "Transfer":U
,
140 "For loading into Outlook 97", "Outlook97":U
142 cmb_PostalType-1
AT ROW 9.9 COL 43.86 COLON-ALIGNED
143 cmb_PostalType-2
AT ROW 11.3 COL 43.86 COLON-ALIGNED
144 cmb_PostalType-3
AT ROW 12.7 COL 43.86 COLON-ALIGNED
145 RP.Log5
AT ROW 16.1 COL 45.86
146 LABEL "Split address into separate lines"
149 RP.Log4
AT ROW 17.6 COL 45.86
150 LABEL "Include 'No Mailout' contacts"
153 RP.Char5
AT ROW 21 COL 7.57 COLON-ALIGNED NO-LABEL FORMAT "X(256)"
156 btn_browse
AT ROW 21 COL 41
157 btn_export
AT ROW 21 COL 56.43
158 btn_cancel
AT ROW 21 COL 67.29
159 RECT-28
AT ROW 1 COL 1.57
160 "Contact Types" VIEW-AS TEXT
161 SIZE 14.86 BY 1 AT ROW 1.5 COL 3.29
163 "Postal Types" VIEW-AS TEXT
164 SIZE 13.72 BY 1 AT ROW 8.5 COL 41.29
166 "Export To:" VIEW-AS TEXT
167 SIZE 8 BY 1 AT ROW 21 COL 1.57
169 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
170 SIDE-LABELS NO-UNDERLINE THREE-D
171 AT COL 1 ROW 1 SCROLLABLE
173 DEFAULT-BUTTON btn_export.
176 /* *********************** Procedure Settings
************************ */
178 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
179 /* Settings for
THIS-PROCEDURE
181 External Tables
: TTPL.RP
182 Allow
: Basic
,DB-Fields
184 Add Fields to
: EXTERNAL-TABLES
185 Other Settings
: PERSISTENT-ONLY
COMPILE
188 /* This procedure should always be
RUN PERSISTENT. Report the error
, */
189 /* then cleanup and return.
*/
190 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
191 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
192 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
196 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
198 /* ************************* Create Window
************************** */
200 &ANALYZE-SUSPEND _CREATE-WINDOW
201 /* DESIGN Window definition
(used by the UIB
)
202 CREATE WINDOW V-table-Win
ASSIGN
205 /* END WINDOW DEFINITION
*/
210 /* *************** Runtime Attributes and UIB Settings
************** */
212 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
213 /* SETTINGS
FOR WINDOW V-table-Win
214 VISIBLE,,RUN-PERSISTENT
*/
215 /* SETTINGS
FOR FRAME F-Main
216 NOT-VISIBLE Size-to-Fit
*/
218 FRAME F-Main
:SCROLLABLE = FALSE
219 FRAME F-Main
:HIDDEN = TRUE.
221 /* SETTINGS
FOR SELECTION-LIST RP.Char1
IN FRAME F-Main
223 /* SETTINGS
FOR FILL-IN RP.Char5
IN FRAME F-Main
224 EXP-LABEL EXP-FORMAT
*/
225 /* SETTINGS
FOR RADIO-SET RP.Char6
IN FRAME F-Main
227 /* SETTINGS
FOR TOGGLE-BOX RP.Log4
IN FRAME F-Main
229 /* SETTINGS
FOR TOGGLE-BOX RP.Log5
IN FRAME F-Main
231 /* _RUN-TIME-ATTRIBUTES-END
*/
235 /* Setting information for Queries and Browse Widgets fields
*/
237 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
238 /* Query rebuild information for
FRAME F-Main
241 */ /* FRAME F-Main
*/
247 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB V-table-Win
248 /* ************************* Included-Libraries
*********************** */
250 {src
/adm
/method
/viewer.i
}
251 {inc
/method
/m-mntvwr.i
}
253 /* _UIB-CODE-BLOCK-END
*/
259 /* ************************ Control Triggers
************************ */
261 &Scoped-define SELF-NAME btn_browse
262 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_browse V-table-Win
263 ON CHOOSE OF btn_browse
IN FRAME F-Main
/* Browse
*/
268 /* _UIB-CODE-BLOCK-END
*/
272 &Scoped-define SELF-NAME btn_cancel
273 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_cancel V-table-Win
274 ON CHOOSE OF btn_cancel
IN FRAME F-Main
/* Cancel
*/
276 RUN dispatch
( 'exit'
:U
).
279 /* _UIB-CODE-BLOCK-END
*/
283 &Scoped-define SELF-NAME btn_export
284 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_export V-table-Win
285 ON CHOOSE OF btn_export
IN FRAME F-Main
/* Export
*/
289 SELF:SENSITIVE = Yes.
290 RUN dispatch
( 'exit'
:U
).
293 /* _UIB-CODE-BLOCK-END
*/
297 &Scoped-define SELF-NAME RP.Char6
298 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL RP.Char6 V-table-Win
299 ON VALUE-CHANGED
OF RP.Char6
IN FRAME F-Main
/* Char6
*/
301 RUN export-style-changed.
304 /* _UIB-CODE-BLOCK-END
*/
308 &Scoped-define SELF-NAME cmb_PostalType-1
309 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_PostalType-1 V-table-Win
310 ON U1
OF cmb_PostalType-1
IN FRAME F-Main
/* First
*/
312 {inc
/selcmb
/scpdt1.i
"RP" "Char2"}
315 /* _UIB-CODE-BLOCK-END
*/
319 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_PostalType-1 V-table-Win
320 ON U2
OF cmb_PostalType-1
IN FRAME F-Main
/* First
*/
322 {inc
/selcmb
/scpdt2.i
"RP" "Char2"}
325 /* _UIB-CODE-BLOCK-END
*/
329 &Scoped-define SELF-NAME cmb_PostalType-2
330 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_PostalType-2 V-table-Win
331 ON U1
OF cmb_PostalType-2
IN FRAME F-Main
/* Second
*/
333 {inc
/selcmb
/scpdt1.i
"RP" "Char3"}
336 /* _UIB-CODE-BLOCK-END
*/
340 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_PostalType-2 V-table-Win
341 ON U2
OF cmb_PostalType-2
IN FRAME F-Main
/* Second
*/
343 {inc
/selcmb
/scpdt2.i
"RP" "Char3"}
346 /* _UIB-CODE-BLOCK-END
*/
350 &Scoped-define SELF-NAME cmb_PostalType-3
351 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_PostalType-3 V-table-Win
352 ON U1
OF cmb_PostalType-3
IN FRAME F-Main
/* Third
*/
354 {inc
/selcmb
/scpdt1.i
"RP" "Char4"}
357 /* _UIB-CODE-BLOCK-END
*/
361 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_PostalType-3 V-table-Win
362 ON U2
OF cmb_PostalType-3
IN FRAME F-Main
/* Third
*/
364 {inc
/selcmb
/scpdt2.i
"RP" "Char4"}
367 /* _UIB-CODE-BLOCK-END
*/
373 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
376 /* *************************** Main Block
*************************** */
378 /* _UIB-CODE-BLOCK-END
*/
382 /* ********************** Internal Procedures
*********************** */
384 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available V-table-Win _ADM-ROW-AVAILABLE
385 PROCEDURE adm-row-available
:
386 /*------------------------------------------------------------------------------
387 Purpose
: Dispatched to this procedure when the Record-
388 Source has a new row available. This procedure
389 tries to get the new row
(or foriegn keys
) from
390 the Record-Source and process it.
392 ------------------------------------------------------------------------------*/
394 /* Define variables needed by this internal procedure.
*/
395 {src
/adm
/template
/row-head.i
}
397 /* Create a list of all the tables that we need to get.
*/
398 {src
/adm
/template
/row-list.i
"RP"}
400 /* Get the record
ROWID's from the RECORD-SOURCE.
*/
401 {src
/adm
/template
/row-get.i
}
403 /* FIND each record specified by the RECORD-SOURCE.
*/
404 {src
/adm
/template
/row-find.i
"RP"}
406 /* Process the newly available records
(i.e. display fields
,
407 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
408 {src
/adm
/template
/row-end.i
}
412 /* _UIB-CODE-BLOCK-END
*/
416 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE browse-file V-table-Win
417 PROCEDURE browse-file
:
418 /*------------------------------------------------------------------------------
422 ------------------------------------------------------------------------------*/
424 DEF VAR save-as
AS CHAR NO-UNDO.
425 DEF VAR file-chosen
AS LOGI
NO-UNDO.
427 save-as
= INPUT FRAME {&FRAME-NAME} RP.Char5.
428 IF LENGTH( save-as
) > 0 THEN
429 IF LOOKUP( SUBSTR( save-as
, LENGTH( save-as
), 1 ), "\,/" ) <> 0 THEN save-as
= "".
431 SYSTEM-DIALOG GET-FILE save-as
432 TITLE "Export Contacts to file"
433 FILTERS "Text Files (*.txt *.csv)" "*.txt,*.csv"
434 DEFAULT-EXTENSION ".csv"
440 IF file-chosen
THEN RP.Char5
:SCREEN-VALUE IN FRAME {&FRAME-NAME} =
445 /* _UIB-CODE-BLOCK-END
*/
449 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI V-table-Win _DEFAULT-DISABLE
450 PROCEDURE disable_UI
:
451 /*------------------------------------------------------------------------------
452 Purpose
: DISABLE the User Interface
454 Notes
: Here we clean-up the user-interface by deleting
455 dynamic widgets we have created and
/or hide
456 frames. This procedure is usually called when
457 we are ready to
"clean-up" after running.
458 ------------------------------------------------------------------------------*/
459 /* Hide all frames.
*/
461 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
464 /* _UIB-CODE-BLOCK-END
*/
468 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE export-contacts V-table-Win
469 PROCEDURE export-contacts
:
470 /*------------------------------------------------------------------------------
474 ------------------------------------------------------------------------------*/
475 DEF VAR report-options
AS CHAR NO-UNDO.
477 IF INPUT FRAME {&FRAME-NAME} RP.Char5 = "" OR
478 INPUT FRAME {&FRAME-NAME} RP.Char5 = "" THEN
480 MESSAGE "You must choose a file to export to!" VIEW-AS ALERT-BOX ERROR
481 TITLE "No file name chosen".
486 RUN dispatch
( 'update-record'
:U
).
490 report-options
= "ExportFor,CONTACT"
491 + "~nContactTypes," + cty-list
492 + "~nFileName," + RP.Char5
493 + "~nAddressTypes," + pty-list
494 + (IF RP.Log5
THEN "~nSplitAddress" ELSE "")
495 + (IF RP.Log4
THEN "~nIncludeNoMailout" ELSE "")
496 + "~nStyle," + RP.Char6 .
498 RUN notify
( 'set-busy
, CONTAINER-SOURCE'
:U
).
499 IF RP.Char6
= "Transfer" THEN
500 RUN process
/export
/dump-contacts.p
( report-options
).
502 RUN process
/export
/contacts.p
( report-options
).
503 RUN notify
( 'set-idle
, CONTAINER-SOURCE'
:U
).
505 MESSAGE "Export Complete" VIEW-AS ALERT-BOX INFORMATION TITLE "Done".
509 /* _UIB-CODE-BLOCK-END
*/
513 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE export-style-changed V-table-Win
514 PROCEDURE export-style-changed
:
515 /*------------------------------------------------------------------------------
517 ------------------------------------------------------------------------------*/
518 DO WITH FRAME {&FRAME-NAME}:
521 DISABLE cmb_PostalType-1 cmb_PostalType-2 cmb_PostalType-3 RP.Log5 .
522 WHEN "Outlook97" THEN
523 DISABLE cmb_PostalType-1 cmb_PostalType-2 cmb_PostalType-3 RP.Log5 .
525 ENABLE cmb_PostalType-1 cmb_PostalType-2 cmb_PostalType-3 RP.Log5 .
530 /* _UIB-CODE-BLOCK-END
*/
534 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-cty-list V-table-Win
535 PROCEDURE get-cty-list
:
536 /*------------------------------------------------------------------------------
540 ------------------------------------------------------------------------------*/
542 DEF VAR delim
AS CHAR NO-UNDO.
543 DEF VAR sv
AS CHAR NO-UNDO.
544 DEF VAR i
AS INT NO-UNDO.
547 delim
= RP.Char1
:DELIMITER IN FRAME {&FRAME-NAME}.
548 sv
= RP.Char1
:SCREEN-VALUE.
550 DO i
= 1 TO NUM-ENTRIES( sv
, delim
):
551 cty-list
= cty-list
+ IF cty-list
= "" THEN "" ELSE ",".
552 cty-list
= cty-list
+ TRIM( ENTRY( 1, ENTRY( i
, sv
, delim
), "-" ) ).
557 /* _UIB-CODE-BLOCK-END
*/
561 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-pty-list V-table-Win
562 PROCEDURE get-pty-list
:
563 /*------------------------------------------------------------------------------
567 ------------------------------------------------------------------------------*/
570 IF RP.Char2
<> "" THEN pty-list
= TRIM( pty-list
+ "," + RP.Char2
, "," ).
571 IF RP.Char3
<> "" THEN pty-list
= TRIM( pty-list
+ "," + RP.Char3
, "," ).
572 IF RP.Char4
<> "" THEN pty-list
= TRIM( pty-list
+ "," + RP.Char4
, "," ).
576 /* _UIB-CODE-BLOCK-END
*/
580 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-enable-fields V-table-Win
581 PROCEDURE inst-enable-fields
:
582 /*------------------------------------------------------------------------------
584 ------------------------------------------------------------------------------*/
585 RUN export-style-changed.
588 /* _UIB-CODE-BLOCK-END
*/
592 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-initialize V-table-Win
593 PROCEDURE inst-initialize
:
594 /*------------------------------------------------------------------------------
598 ------------------------------------------------------------------------------*/
600 DEF VAR user-name
AS CHAR NO-UNDO.
602 RUN get-username
IN sys-mgr
( OUTPUT user-name
).
603 RUN update-contact-types.
606 RP.UserName
= user-name
AND
607 RP.ReportID
= {&REPORT-ID} NO-ERROR.
609 IF NOT AVAILABLE RP
THEN
610 DO WITH FRAME {&FRAME-NAME}:
614 RP.ReportID
= {&REPORT-ID}
615 RP.UserName
= user-name
620 RUN dispatch
( 'row-changed'
:U
).
621 RUN dispatch
( 'enable-fields'
:U
).
625 /* _UIB-CODE-BLOCK-END
*/
629 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-destroy V-table-Win
630 PROCEDURE pre-destroy
:
631 /*------------------------------------------------------------------------------
635 ------------------------------------------------------------------------------*/
637 RUN check-modified
( "CLEAR" ).
641 /* _UIB-CODE-BLOCK-END
*/
645 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records V-table-Win _ADM-SEND-RECORDS
646 PROCEDURE send-records
:
647 /*------------------------------------------------------------------------------
648 Purpose
: Send record
ROWID's for all tables used by
650 Parameters
: see template
/snd-head.i
651 ------------------------------------------------------------------------------*/
653 /* Define variables needed by this internal procedure.
*/
654 {src
/adm
/template
/snd-head.i
}
656 /* For each requested table
, put it's
ROWID in the output list.
*/
657 {src
/adm
/template
/snd-list.i
"RP"}
659 /* Deal with any unexpected table requests before closing.
*/
660 {src
/adm
/template
/snd-end.i
}
664 /* _UIB-CODE-BLOCK-END
*/
668 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
669 PROCEDURE state-changed
:
670 /* -----------------------------------------------------------
674 -------------------------------------------------------------*/
675 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
676 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
679 /* Object instance CASEs can go here to replace standard behavior
681 {src
/adm
/template
/vstates.i
}
685 /* _UIB-CODE-BLOCK-END
*/
689 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-contact-types V-table-Win
690 PROCEDURE update-contact-types
:
691 /*------------------------------------------------------------------------------
695 ------------------------------------------------------------------------------*/
697 DEF VAR item
AS CHAR NO-UNDO.
699 FOR EACH ContactType
NO-LOCK:
700 item
= STRING( ContactType.ContactType
, "X(6)" ) + " - " + ContactType.Description.
701 IF RP.Char1
:ADD-LAST( item
) IN FRAME {&FRAME-NAME} THEN.
706 /* _UIB-CODE-BLOCK-END
*/