-
Notifications
You must be signed in to change notification settings - Fork 23
/
wQueryEditor.w
672 lines (535 loc) · 20.8 KB
/
wQueryEditor.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
&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI
&ANALYZE-RESUME
&Scoped-define WINDOW-NAME C-Win
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS C-Win
/* Header goes here
*/
{DataDigger.i}
CREATE WIDGET-POOL.
DEFINE INPUT PARAMETER phParentWindow AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER TABLE FOR ttField.
DEFINE INPUT-OUTPUT PARAMETER pcQuery AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER plOk AS LOGICAL NO-UNDO.
/* _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 frWhere
/* Standard List Definitions */
&Scoped-Define ENABLED-OBJECTS btnBegins rctQueryButtons cbAndOr cbFields ~
cbOperator ficValue btnInsert ficWhere btnOr btnOK btnCancel btnAnd ~
btnBracket btnContains btnEq btnGT btnLT btnMatches btnNE btnQt btnToday
&Scoped-Define DISPLAYED-OBJECTS cbAndOr cbFields cbOperator ficValue ~
ficWhere
/* Custom List Definitions */
/* List-1,List-2,List-3,List-4,List-5,List-6 */
&Scoped-define List-1 btnBegins rctQueryButtons cbAndOr cbFields cbOperator ~
ficValue btnInsert btnOr btnAnd btnBracket btnContains btnEq btnGT btnLT ~
btnMatches btnNE btnQt btnToday
/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME
/* *********************** Control Definitions ********************** */
/* Define the widget handle for the window */
DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.
/* Definitions of the field level widgets */
DEFINE BUTTON btnAnd NO-FOCUS
LABEL "and"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 40 BY 21 TOOLTIP "insert this text into the where field".
DEFINE BUTTON btnBegins NO-FOCUS
LABEL "begins"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 80 BY 21 TOOLTIP "insert this text into the where field".
DEFINE BUTTON btnBracket NO-FOCUS
LABEL "()"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 40 BY 21 TOOLTIP "insert this text into the where field"
FONT 0.
DEFINE BUTTON btnCancel DEFAULT
LABEL "Cancel"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 75 BY 24
BGCOLOR 8 .
DEFINE BUTTON btnContains NO-FOCUS
LABEL "contains"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 80 BY 21 TOOLTIP "insert this text into the where field".
DEFINE BUTTON btnEq NO-FOCUS
LABEL "="
CONTEXT-HELP-ID 1050
SIZE-PIXELS 40 BY 21 TOOLTIP "insert this text into the where field".
DEFINE BUTTON btnGT NO-FOCUS
LABEL ">"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 40 BY 21 TOOLTIP "insert this text into the where field".
DEFINE BUTTON btnInsert
LABEL "+"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 20 BY 23 TOOLTIP "insert the expression into the where field".
DEFINE BUTTON btnLT NO-FOCUS
LABEL "<"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 40 BY 21 TOOLTIP "insert this text into the where field".
DEFINE BUTTON btnMatches NO-FOCUS
LABEL "matches"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 80 BY 21 TOOLTIP "insert this text into the where field".
DEFINE BUTTON btnNE NO-FOCUS
LABEL "<>"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 40 BY 21 TOOLTIP "insert this text into the where field".
DEFINE BUTTON btnOK AUTO-GO DEFAULT
LABEL "OK"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 75 BY 24
BGCOLOR 8 .
DEFINE BUTTON btnOr NO-FOCUS
LABEL "or"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 40 BY 21 TOOLTIP "insert this text into the where field".
DEFINE BUTTON btnQt NO-FOCUS
LABEL "~"~""
CONTEXT-HELP-ID 1050
SIZE-PIXELS 40 BY 21 TOOLTIP "insert this text into the where field"
FONT 0.
DEFINE BUTTON btnToday NO-FOCUS
LABEL "today"
CONTEXT-HELP-ID 1050
SIZE-PIXELS 80 BY 21 TOOLTIP "insert this text into the where field".
DEFINE VARIABLE cbAndOr AS CHARACTER FORMAT "X(256)":U
LABEL "&Where"
CONTEXT-HELP-ID 1050
VIEW-AS COMBO-BOX INNER-LINES 5
LIST-ITEMS "","AND","OR"
DROP-DOWN-LIST
SIZE-PIXELS 50 BY 21 TOOLTIP "preceding AND or OR for the expression" NO-UNDO.
DEFINE VARIABLE cbFields AS CHARACTER FORMAT "X(256)":U
CONTEXT-HELP-ID 1050
VIEW-AS COMBO-BOX SORT INNER-LINES 10
DROP-DOWN-LIST
SIZE-PIXELS 186 BY 21 TOOLTIP "field used in the expression"
FONT 2 NO-UNDO.
DEFINE VARIABLE cbOperator AS CHARACTER FORMAT "X(256)":U
CONTEXT-HELP-ID 1050
VIEW-AS COMBO-BOX INNER-LINES 10
LIST-ITEMS "","=","<>",">",">=","<","<=","begins","matches","contains"
DROP-DOWN-LIST
SIZE-PIXELS 85 BY 21 TOOLTIP "operator used in the expression"
FONT 2 NO-UNDO.
DEFINE VARIABLE ficWhere AS CHARACTER
CONTEXT-HELP-ID 1050
VIEW-AS EDITOR SCROLLBAR-VERTICAL
SIZE-PIXELS 501 BY 175 TOOLTIP "alt-cursor-up / down to view/hide query editor"
FONT 2 NO-UNDO.
DEFINE VARIABLE ficValue AS CHARACTER FORMAT "X(256)":U
CONTEXT-HELP-ID 1050
VIEW-AS FILL-IN
SIZE-PIXELS 210 BY 23 TOOLTIP "the literal value for the expression"
FONT 2 NO-UNDO.
DEFINE RECTANGLE rctQueryButtons
EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
SIZE-PIXELS 610 BY 190.
/* ************************ Frame Definitions *********************** */
DEFINE FRAME frWhere
btnBegins AT Y 123 X 17
cbAndOr AT Y 5 X 46 COLON-ALIGNED
cbFields AT Y 5 X 100 COLON-ALIGNED NO-LABEL
cbOperator AT Y 5 X 286 COLON-ALIGNED NO-LABEL
ficValue AT Y 5 X 371 COLON-ALIGNED NO-LABEL
btnInsert AT Y 5 X 595
ficWhere AT Y 35 X 110 NO-LABEL
btnOr AT Y 101 X 57
btnOK AT Y 231 X 460
btnCancel AT Y 231 X 540
btnAnd AT Y 101 X 17
btnBracket AT Y 79 X 17
btnContains AT Y 145 X 17
btnEq AT Y 35 X 17
btnGT AT Y 57 X 57
btnLT AT Y 57 X 17
btnMatches AT Y 167 X 17
btnNE AT Y 35 X 57
btnQt AT Y 79 X 57
btnToday AT Y 189 X 17
"or ESC to undo your changes" VIEW-AS TEXT
SIZE-PIXELS 340 BY 15 AT Y 243 X 9
FGCOLOR 7
"Use ALT-UP to take the query back to the main window" VIEW-AS TEXT
SIZE-PIXELS 340 BY 15 AT Y 227 X 10
FGCOLOR 7
rctQueryButtons AT Y 30 X 5
WITH 1 DOWN KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1
SIZE 124.8 BY 13.71
TITLE "Query Editor".
/* *********************** 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
/* SUPPRESS Window definition (used by the UIB)
IF SESSION:DISPLAY-TYPE = "GUI":U THEN
CREATE WINDOW C-Win ASSIGN
HIDDEN = YES
TITLE = "Query Editor"
HEIGHT = 13.76
WIDTH = 126
MAX-HEIGHT = 14.05
MAX-WIDTH = 136
VIRTUAL-HEIGHT = 14.05
VIRTUAL-WIDTH = 136
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
ASSIGN C-Win = CURRENT-WINDOW.
/* *********** Runtime Attributes and AppBuilder Settings *********** */
&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW C-Win
VISIBLE,,RUN-PERSISTENT */
/* SETTINGS FOR FRAME frWhere
FRAME-NAME */
ASSIGN
FRAME frWhere:MOVABLE = TRUE.
/* SETTINGS FOR BUTTON btnAnd IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnBegins IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnBracket IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnContains IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnEq IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnGT IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnInsert IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnLT IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnMatches IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnNE IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnOr IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnQt IN FRAME frWhere
1 */
/* SETTINGS FOR BUTTON btnToday IN FRAME frWhere
1 */
/* SETTINGS FOR COMBO-BOX cbAndOr IN FRAME frWhere
1 */
/* SETTINGS FOR COMBO-BOX cbFields IN FRAME frWhere
1 */
/* SETTINGS FOR COMBO-BOX cbOperator IN FRAME frWhere
1 */
/* SETTINGS FOR FILL-IN ficValue IN FRAME frWhere
1 */
ASSIGN
ficWhere:RETURN-INSERTED IN FRAME frWhere = TRUE.
/* SETTINGS FOR RECTANGLE rctQueryButtons IN FRAME frWhere
1 */
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME
/* ************************ Control Triggers ************************ */
&Scoped-define SELF-NAME C-Win
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
ON END-ERROR OF C-Win /* Query Editor */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE
DO:
APPLY "CLOSE" TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
ON WINDOW-CLOSE OF C-Win /* Query Editor */
DO:
/* This event will close the window and terminate the procedure. */
APPLY "CLOSE" TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME frWhere
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL frWhere C-Win
ON ALT-W OF FRAME frWhere /* Query Editor */
ANYWHERE DO:
APPLY 'entry' TO cbAndOr.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL frWhere C-Win
ON GO OF FRAME frWhere /* Query Editor */
OR 'ALT-CURSOR-UP' OF FRAME frWhere ANYWHERE
DO:
pcQuery = formatQueryString(ficWhere:SCREEN-VALUE, NO).
plOk = TRUE.
APPLY "CLOSE" TO THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnAnd
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnAnd C-Win
ON CHOOSE OF btnAnd IN FRAME frWhere /* and */
, btnOr, btnEq, btnNe, btnGt, btnLt, btnToday, btnMatches, btnContains, btnBegins
DO:
/* No text selected */
IF ficWhere:SELECTION-TEXT = "" THEN
ficWhere:INSERT-STRING(SUBSTITUTE(' &1 ', SELF:LABEL)).
ELSE
ficWhere:REPLACE-SELECTION-TEXT(SUBSTITUTE(' &1 ', SELF:LABEL)).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnBracket
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnBracket C-Win
ON CHOOSE OF btnBracket IN FRAME frWhere /* () */
DO:
/* No text selected */
IF ficWhere:SELECTION-TEXT = "" THEN
DO:
ficWhere:INSERT-STRING(SUBSTITUTE(' &1 ', SELF:LABEL)).
ficWhere:CURSOR-OFFSET = ficWhere:CURSOR-OFFSET - 2.
END.
ELSE
ficWhere:REPLACE-SELECTION-TEXT(SUBSTITUTE(' ( &1 ) ', ficWhere:SELECTION-TEXT)).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnCancel
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnCancel C-Win
ON CHOOSE OF btnCancel IN FRAME frWhere /* Cancel */
OR 'LEAVE' OF {&WINDOW-NAME}
DO:
plOk = NO.
APPLY "CLOSE" TO THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnInsert
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnInsert C-Win
ON CHOOSE OF btnInsert IN FRAME frWhere /* + */
OR "return" OF ficValue
DO:
DEFINE BUFFER bField FOR ttField.
DEFINE VARIABLE cField AS CHARACTER NO-UNDO.
FIND bField WHERE bField.cFullName = cbFields:SCREEN-VALUE NO-ERROR.
IF NOT AVAILABLE bField THEN RETURN.
cField = bField.cFullName.
IF cField = 'RECID' OR cField = 'ROWID'
THEN cField = SUBSTITUTE('&1(&2)', cField, bField.cTablename ).
ficWhere:INSERT-STRING(LEFT-TRIM(SUBSTITUTE('&1 &2 &3 &4&5'
, (IF cbAndOr:SCREEN-VALUE = ? THEN '' ELSE cbAndOr:SCREEN-VALUE)
, cField
, cbOperator:SCREEN-VALUE
, IF bField.cDataType = 'character' THEN QUOTER(ficValue:SCREEN-VALUE) ELSE ficValue:SCREEN-VALUE
, CHR(13)
)
)
).
APPLY "entry" TO cbAndOr.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnQt
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnQt C-Win
ON CHOOSE OF btnQt IN FRAME frWhere /* "" */
DO:
/* No text selected */
IF ficWhere:SELECTION-TEXT = "" THEN
DO:
ficWhere:INSERT-STRING(SUBSTITUTE(' &1 ', SELF:LABEL)).
ficWhere:CURSOR-OFFSET = ficWhere:CURSOR-OFFSET - 2.
END.
ELSE
ficWhere:REPLACE-SELECTION-TEXT(SUBSTITUTE('"&1"', ficWhere:SELECTION-TEXT)).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbAndOr
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbAndOr C-Win
ON RETURN OF cbAndOr IN FRAME frWhere /* Where */
DO:
APPLY 'entry' TO cbFields.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbFields
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbFields C-Win
ON RETURN OF cbFields IN FRAME frWhere
DO:
APPLY 'entry' TO cbOperator.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME cbOperator
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbOperator C-Win
ON RETURN OF cbOperator IN FRAME frWhere
DO:
APPLY 'entry' TO ficValue.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME ficValue
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ficValue C-Win
ON ENTRY OF ficValue IN FRAME frWhere
DO:
IF SELF:screen-value = "" THEN
SELF:screen-value = getLinkInfo(cbFields:screen-value).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME ficWhere
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ficWhere C-Win
ON CTRL-A OF ficWhere IN FRAME frWhere
DO:
SELF:SET-SELECTION(1,LENGTH(SELF:SCREEN-VALUE) + NUM-ENTRIES(SELF:SCREEN-VALUE,'~n')).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ficWhere C-Win
ON CTRL-D OF ficWhere IN FRAME frWhere
DO:
DEFINE VARIABLE i AS INTEGER NO-UNDO.
i = SELF:CURSOR-OFFSET.
SELF:SET-SELECTION(0,0).
SELF:CURSOR-OFFSET = i.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&UNDEFINE SELF-NAME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK C-Win
/* *************************** 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 initObject.
IF NOT THIS-PROCEDURE:PERSISTENT THEN
WAIT-FOR CLOSE OF THIS-PROCEDURE FOCUS ficWhere.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ********************** Internal Procedures *********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI C-Win _DEFAULT-DISABLE
PROCEDURE disable_UI :
/*------------------------------------------------------------------------------
Purpose: DISABLE the User Interface
Parameters: <none>
Notes: Here we clean-up the user-interface by deleting
dynamic widgets we have created and/or hide
frames. This procedure is usually called when
we are ready to "clean-up" after running.
------------------------------------------------------------------------------*/
/* Hide all frames. */
HIDE FRAME frWhere.
IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI C-Win _DEFAULT-ENABLE
PROCEDURE enable_UI :
/*------------------------------------------------------------------------------
Purpose: ENABLE the User Interface
Parameters: <none>
Notes: Here we display/view/enable the widgets in the
user-interface. In addition, OPEN all queries
associated with each FRAME and BROWSE.
These statements here are based on the "Other
Settings" section of the widget Property Sheets.
------------------------------------------------------------------------------*/
DISPLAY cbAndOr cbFields cbOperator ficValue ficWhere
WITH FRAME frWhere.
ENABLE btnBegins rctQueryButtons cbAndOr cbFields cbOperator ficValue
btnInsert ficWhere btnOr btnOK btnCancel btnAnd btnBracket btnContains
btnEq btnGT btnLT btnMatches btnNE btnQt btnToday
WITH FRAME frWhere.
{&OPEN-BROWSERS-IN-QUERY-frWhere}
VIEW C-Win.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE initObject C-Win
PROCEDURE initObject :
/* Init
*/
DEFINE VARIABLE iDefaultFont AS INTEGER NO-UNDO.
DEFINE VARIABLE iFixedFont AS INTEGER NO-UNDO.
DEFINE VARIABLE cFieldList AS CHARACTER NO-UNDO.
DO WITH FRAME frWhere:
iDefaultFont = getFont("Default").
iFixedFont = getFont("Fixed").
{&_proparse_ prolint-nowarn(overflow)}
ASSIGN
FRAME frWhere:FONT = iDefaultFont
FRAME frWhere:X = (phParentWindow:WIDTH-PIXELS - FRAME frWhere:WIDTH-PIXELS) / 2
FRAME frWhere:Y = (phParentWindow:HEIGHT-PIXELS - FRAME frWhere:HEIGHT-PIXELS) / 2.
cbAndOr:FONT = iFixedFont.
cbFields:FONT = iFixedFont.
cbOperator:FONT = iFixedFont.
ficValue:FONT = iFixedFont.
ficWhere:FONT = iFixedFont.
btnEq:FONT = iFixedFont.
btnNe:FONT = iFixedFont.
btnGt:FONT = iFixedFont.
btnLt:FONT = iFixedFont.
btnBracket:FONT = iFixedFont.
btnQt:FONT = iFixedFont.
btnAnd:FONT = iFixedFont.
btnOr:FONT = iFixedFont.
btnBegins:FONT = iFixedFont.
btnContains:FONT = iFixedFont.
btnMatches:FONT = iFixedFont.
btnToday:FONT = iFixedFont.
btnInsert:LOAD-IMAGE(getImagePath("Add.gif")).
ficValue:TOOLTIP = ficValue:TOOLTIP + "~n~n(CTRL-ENTER) execute".
ficWhere:TOOLTIP = ficWhere:TOOLTIP + "~n~n(CTRL-ENTER) execute".
/* Get a list of all fields (extents NOT expanded) */
FOR EACH ttField:
cFieldList = cFieldList + ',' + ttField.cFullname.
END.
/* Set list of fields in field combo */
cbFields:LIST-ITEMS = cFieldList.
cbAndOr:SCREEN-VALUE = ENTRY(1,cbAndOr:LIST-ITEMS).
cbFields:SCREEN-VALUE = ENTRY(1,cbFields:LIST-ITEMS).
cbOperator:SCREEN-VALUE = ENTRY(1,cbOperator:LIST-ITEMS).
RUN enable_UI.
pcQuery = formatQueryString(pcQuery, YES).
ficWhere:SCREEN-VALUE = pcQuery.
ficWhere:CURSOR-OFFSET = LENGTH(pcQuery) + NUM-ENTRIES(pcQuery,'~n') + 1.
END.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME