-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebuger.clw
1464 lines (1315 loc) · 65.4 KB
/
debuger.clw
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
MEMBER
!Region Module Level
!Updates (to copy to the .inc)
!Sept-18-06 MG: changed OMIT/COMPILES for HOWMANY() to be C61 vs. C60
! .DumpControls sort by FEQ
! .ShowControl re-order columns to lead to show columns with more consistent widths first, making it easier to read.
! CREATE:ComboButton in .DescribeType
INCLUDE('debuger.inc'),ONCE
INCLUDE('equates.clw'),ONCE
INCLUDE('FileAccessModes.EQU'),ONCE
Verbose EQUATE(1) !0..N
COMPILE('***',_width32_)
ANSI_NAME EQUATE('A')
! ***
OMIT('***',_width32_)
ANSI_NAME EQUATE('')
! ***
MAP
MODULE('Winapi')
!see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/debugging_functions.asp
!see http://msdn.microsoft.com/en-us/library/windows/desktop/ms679297(v=vs.85).aspx
debugbreak(),PASCAL !,RAW,NAME('debugbreak')
OutputDebugSTRING(*CSTRING),PASCAL,RAW,NAME('OutputDebugString' & ANSI_NAME)
END
MODULE('C%V%RUN%X%')
debugerNameMessage (*CSTRING, UNSIGNED EventNum ),RAW,NAME('WslDebug$NameMessage') !Note: use Event() + EVENT:FIRST else will get WM_*
COMPILE('** C55+ **',_C55_)
debugerGetFieldName(SIGNED FEQ ),*CSTRING,RAW,NAME('Cla$FIELDNAME')
!END-COMPILE('** C55+ **',_C55_)
OMIT('** C55+ **',_C55_)
debugerGetFieldName(SIGNED FEQ ),LONG,RAW,NAME('Cla$FIELDNAME')
!END-OMIT('** C55+ **',_C55_)
END
MyAssertHook2 (UNSIGNED LineNumber, STRING filename, STRING message) !Not technically part of the class
ODS(STRING msg),NAME('debuger_ods') !<-- was getting duplicate symbols
END
PRAGMA('define(profile=>off)')
COMPILE('***',profile)
! @===========================================================================================
! Don`t try and profile this, you get infinite recursion (when used by EnterProc/LeaveProc)
! Set profile=>off on this module in the project
! Note: in C6, profile=>off possibly renamed to proc_trace=>off
!
This comment will prevent you from compiling unless profile=>off on this modu1e
! @===========================================================================================
!end-COMPILE('***',profile)
!OMIT('_ifdef_',EVENT:APP=08000h)
COMPILE('_ifdef_',EVENT:APP=0)
EVENT:APP EQUATE(08000h)
EVENT:APP_LAST EQUATE(0BFFFh)
!END_COMPILE('_ifdef_',EVENT:APP=0)
DebugersQ QUEUE !added to handle multiple instances cleaner.
Debuger &Debuger
END
!module_Debuger &Debuger
MOD:ClearedInInit BYTE(FALSE)
Suffix EQUATE('<13,10>')
!EndRegion Module Level
!Region Procedures (not methods)
!-----------------------------------------------------------------------------------------!
ODS PROCEDURE(STRING msg)
!Helper function, to be used internally to the class when the class itself for debugging the class
sz &CSTRING
CODE
sz &= NEW CSTRING( SIZE(msg) + SIZE(Suffix) + 1 )
sz = msg & Suffix
OutputDebugSTRING(sz)
DISPOSE(sz)
!-----------------------------------------------------------------------------------------!
MyAssertHook2 PROCEDURE(UNSIGNED LineNumber, STRING filename, STRING argMSG) !Not technically part of the class
!Note: ASSERT will ONLY call this procedure if you have compiled with Debugging On or asserts=>on
!FYI: I found doc. re: asserts on in the C60help.hlp under ASSERT()
!Useage: Assert(0,eqDBG&'Message to display')
!Purpose: Will add MODULE/LineNumber to output
! also makes it easy to call the debuger, from modules with an empty member, hence no debuger instance in scope
!Updated: Size(eqDBG) replaced with LEN(eqDBG) so this code can be used in C5
! Aug 8, 2005 - added .MatchAssertMsg logic, moved GPF logic to a ROUTINE
!
!NOTE: module_Debuger is set in Set_Module_Debuger() called via .INIT
! there CAN be problems when there are multiple debuger classes around.
! especially since there is no stack used for the Module_Debugger
! problems: a) using the "wrong" debuger
! b) the last debuger to call .Set_module_debuger has been de-instantiated, but others AssertHook2 is still in effect
!Replaced Module_Debuger with DebugersQ.Debuger
DEBUGMSG BYTE,AUTO
Matched LONG,AUTO
CODE
!ODS('`MyAssertHook2 Debuger Absent?['& CHOOSE( DebugersQ.Debuger &= NULL) &'] Records(DebugersQ)['& RECORDS(DebugersQ) &'] POINTER(DebugersQ)['& POINTER(DebugersQ) &'] argMSG['& sub(argMSG,1,1024) &']')
!GET(DebugersQ, RECORDS(DebugersQ))
!ODS('`MyAssertHook2 Debuger Absent?['& CHOOSE( DebugersQ.Debuger &= NULL) &'] Records(DebugersQ)['& RECORDS(DebugersQ) &'] POINTER(DebugersQ)['& POINTER(DebugersQ) &'] argMSG['& sub(argMSG,1,1024) &']')
!ODS('`MyAssertHook2')
IF LEN(argMSG) >= LEN(eqDBG) AND argMSG[ 1 : LEN(eqDBG) ] = eqDBG
DEBUGMSG = TRUE
IF LEN(argMSG) = LEN(eqDBG) !added Nov 7, 2003 (after getting index out of range errors)
argMSG = ''
ELSE
argMSG = argMSG[ LEN(eqDBG) + 1 : SIZE(argMSG) ]
END
ELSE
DEBUGMSG = FALSE
END
!ODS('`DEBUGMSG['& DEBUGMSG &']')
IF NOT (DebugersQ.Debuger &= NULL)
IF DEBUGMSG
! DebugersQ.Debuger.DebugOut('in['& CLIP(filename) &' @'& LineNumber &'] Thread['& THREAD() &'] '& argMSG )
DebugersQ.Debuger.ODS('in['& CLIP(filename) &' @'& LineNumber &'] Thread['& THREAD() &'] '& argMSG )
ELSE
Matched = DebugersQ.Debuger.MatchAssertMsg(LineNumber, FileName, argMSG)
DebugersQ.Debuger.DebugOut('Debuger, Matched['& Matched &']=['& DebugersQ.Debuger.DescribeAction(Matched) &'] MatchedTo['& DebugersQ.Debuger.AssertMessagesQ.szMSG &']')
IF DebugersQ.Debuger.AssertHookAction(Matched, LineNumber, FileName, argMSG) = 0
!DebugersQ.Debuger.DebugOut('Past AssertHookAction Debuger, Matched['& Matched &']')
CASE Matched
OF AssertMsgAction::IGNORE
!do nothing
OF AssertMsgAction::AUTOGPF
DebugersQ.Debuger.DebugOut('Assertion failed in['& CLIP(filename) &' @'& LineNumber &'] '& argMSG )
DO MyAssertHook2::GPFNOW
OF AssertMsgAction::NOMATCH
OROF AssertMsgAction::PROMPT
DebugersQ.Debuger.DebugOut('Assertion failed in['& CLIP(filename) &' @'& LineNumber &'] '& argMSG )
DebugersQ.Debuger.ShowMessageWindow('Assertion failed in ['& CLIP(filename) &' @'& LineNumber &']'& |
CHOOSE(LEN(CLIP(argMSG))>0,'||'& CLIP(argMSG),''), 'ASSERT')
END !case Matched
END
END
ELSE
IF DEBUGMSG
ODS('`in['& CLIP(filename) &' @'& LineNumber &'] '& argMSG ) !+ Oct/12/06
!ODS('`About to Call MESSAGE, no debuger present')
ELSE !~Aug/29/08 MG : behavior changed, ise DEBUGMSG, the avoid the offer to GPF
CASE MESSAGE('Assertion failed in ['& CLIP(filename) &'] @['& LineNumber &']'& |
CHOOSE(LEN(CLIP(argMSG))>0,'||'& CLIP(argMSG),''), |
'ASSERT', ICON:Exclamation, '&Continue|&Halt',1)
OF 1; !do nothing
OF 2; DO MyAssertHook2::GPFNOW
END !case
END
END
!----------------------------------------------------
MyAssertHook2::GPFNOW ROUTINE
!data
!lZero long
! code
!ODS('`MyAssertHook2::GPFNOW')
SYSTEM{prop:asserthook} = 0 !Stop recursive calls into assert handler
SYSTEM{prop:asserthook2} = 0 !Stop recursive calls into assert handler
debugbreak()
!lZero = 0
!lZero = lZero / lZero !Causes a divide by zero GPF -- no longers works (tested in C6.9034)
!ODS('`MyAssertHook2::GPFNOW POST GPF lZero['& lZero &']')
EXIT
!EndRegion Procedures (not methods)
!Region DebugerAutoInit
!-----------------------------------------------------------------------------------------!
DebugerAutoInit.CONSTRUCT PROCEDURE
CODE
!ODS('`DebugerAutoInit.construct'& Suffix)
SELF.mg_init('AutoInit')
!EndRegion DebugerAutoInit
!Region Debuger Methods
Debuger.CONSTRUCT PROCEDURE
CODE
!ODS('`Debuger.construct [start]'& Suffix)
!ODS('`Debuger.construct SELF['& ADDRESS(SELF) &'] Records(DebugersQ)['& RECORDS(DebugersQ) &'] Pointer['& POINTER(DebugersQ) &']'& Suffix)
!SELF.Set_Module_Debuger()
RETURN
!-----------------------------------------------------------------------------------------!
Debuger.mg_init PROCEDURE(STRING ProgramName)
CODE
SELF.Init(ProgramName,DEBUGER::ENABLED,0,DEBUGER::CLEAR_CMDLINE,DEBUGER::ASCII_NEVER) !DEBUGER::ASCII_PROMPT
SELF.AddAssertMsg(0,'^PrintEvent',AssertMsgAction::PrintEvent, Match:Regular + Match:NoCase )
!-----------------------------------------------------------------------------------------!
Debuger.init PROCEDURE(STRING argPgmname,BYTE argOSmode,SHORT argDuplicates,BYTE argClear, BYTE argAsciiByDefault)
CODE
SELF.DebugFilter = '`'
SELF.AppendCRLF = TRUE !mg Feb/5/04 -- may wish to turn off "Options->Force Carrigage Returns" in debugView
SELF.pgmname = argPgmname
SELF.osmode = argOSmode !this parameter if true, turns on debug regaredless of project setting
SELF.duplicates = argDuplicates ! default number of same debug messages in a row before a warning message is issued
CASE argOSMode
OF DEBUGER::DISABLED ; SELF.DebugActive = FALSE
OF DEBUGER::ENABLED ; SELF.DebugActive = TRUE
OF DEBUGER::ENABLE_CMDLINE ; SELF.DebugActive = CHOOSE( COMMAND('/Debuger') <> '' )
ELSE ; SELF.DebugActive = TRUE
END
! SELF.DebugOut('Debuger MOD:ClearedInInit['&MOD:ClearedInInit&'] argClear['&argClear&'] command(''/clear'')['&command('/clear')&'] SELF.debugactive['&SELF.debugactive&']')
IF ~MOD:ClearedInInit
CASE argClear
OF DEBUGER::CLEAR_ALWAYS ; SELF.ClearLog(); MOD:ClearedInInit=TRUE
OF DEBUGER::CLEAR_CMDLINE; IF COMMAND('/Clear') THEN SELF.ClearLog(); MOD:ClearedInInit=TRUE END
END !case
END
IF SELF.DebugActive
IF Verbose > 0
SELF.delayOut('Program['& CLIP(COMMAND(0)) &'] ')
IF SELF.osmode THEN SELF.debugout('DebugerOn[Always]') ! force debug on regardless of debug in project
ELSE SELF.debugout('DebugerOn[Command line]') ! force debug on a production app
END
END
IF Verbose > 3
SELF.debugout('Debuger Class last modified['& CLIP(FORMAT(DATE(12,11,2009),@D18)) &']')
SELF.debugout('Debuger Class Updates: http://www.monolithcc.com/clarion/debuger.zip')
SELF.DebugOut ('-{90}')
SELF.debugout('')
END
END
SELF.Set_dumpQue_DefaultFileName('ExportQ.csv')
SELF.Set_dumpQue_AsciiByDefault(argAsciiByDefault)
DO Init::SetEventOffset
SELF.Set_Module_Debuger() !moved .Construct
SELF.Set_AssertHook2()
SELF.UserEventNameQ &= NEW qtUserEventName; CLEAR(SELF.UserEventNameQ)
SELF.AddUserEvent('EVENT:DoResize',EVENT:User-1)
SELF.AssertMessagesQ &= NEW qtAssertMessages; CLEAR(SELF.AssertMessagesQ)
IF Verbose > 3 THEN ODS(SELF.DebugFilter &'Debuger.init [end]') END
!-------------------------------------
Init::SetEventOffset ROUTINE
!Purpose: set SELF.EventOffset which varies with the version of CW
! this value is used by GetEventDescr to determine when to call WslDebug$NameMessage
DATA
EventNum LONG
Pass BYTE
Lo LONG
Hi LONG
CODE
COMPILE('**++** _C60_Plus_',_C60_)
SELF.EventOffset = 0A000h
! **++** _C60_Plus_
OMIT ('**--** _PRE_C6_',_C60_)
SELF.EventOffset = 01400h
! **--** _PRE_C6_
IF UPPER(SELF.GetEventDescr(EVENT:ACCEPTED)) = 'EVENT:ACCEPTED' THEN EXIT END
SELF.DebugOut('SELF.EventOffset is not correct, trying to find a correct value')
SELF.EventOffset = CHOOSE(SELF.EventOffset = 01400h, 0A000h, 01400h)
if UPPER(SELF.GetEventDescr(EVENT:ACCEPTED)) = 'EVENT:ACCEPTED' THEN EXIT END
SELF.EventOffset = GETINI('Debuger','EventOffset', -1)
CASE SELF.EventOffset
OF -2; SELF.DebugOut('Stored value for EventOffset indicates no valid offset to be found, not searching')
OF -1; SELF.DebugOut('SELF.EventOffset is not correct, searching for correct value')
ELSE ; IF UPPER(SELF.GetEventDescr(EVENT:ACCEPTED)) = 'EVENT:ACCEPTED'
SELF.DebugOut('Using stored value for SELF.EventOffset')
EXIT
END
END
!The loops are split out to search more likely ranges first
!for efficiency it makes more sense to check offsets incrementing by 100, searching for a result that starts with 'EVENT'
LOOP Pass = 1 TO 4
EXECUTE Pass
BEGIN; Lo = 0A000h; Hi = 0AFFFh END
BEGIN; Lo = 01000h; Hi = 01FFFh END
BEGIN; Lo = 00000h; Hi = 00FFFh END
BEGIN; Lo = 0B000h; Hi = 0FFFFh END
END
LOOP EventNum = Lo TO Hi
SELF.EventOffset = EventNum
IF UPPER(SELF.GetEventDescr(EVENT:ACCEPTED)) = 'EVENT:ACCEPTED'
PUTINI('Debuger','EventOffset',SELF.EventOffset)
EXIT
END
END
END
SELF.DebugOut('Could not find a working offset for .EventOffset')
SELF.EventOffset = -2
PUTINI('Debuger','EventOffset',SELF.EventOffset)
!-----------------------------------------------------------------------------------------!
Debuger.destruct PROCEDURE()
CODE
IF Verbose > 5 THEN ODS('`Debuger.Destruct v') END
SELF.kill()
IF Verbose > 5 THEN ODS('`Debuger.Destruct ^') END
!-----------------------------------------------------------------------------------------!
Debuger.kill PROCEDURE()
CODE
IF Verbose > 5 THEN ODS('`Debuger.kill (start) pgmname['& SELF.pgmname &'] SELF['& ADDRESS(SELF) &'] Records(DebugersQ)['& RECORDS(DebugersQ) &']') END
IF SELF.debugactive
SELF.debugout('Program['& CLIP(COMMAND(0)) &'] Ended ['& CLIP(FORMAT(TODAY(),@D18)) &' '& CLIP(FORMAT(CLOCK(),@T8)) &']')
SELF.debugactive = FALSE
END
IF ~(SELF.UserEventNameQ &= NULL)
FREE (SELF.UserEventNameQ)
DISPOSE(SELF.UserEventNameQ)
END
IF ~(SELF.AssertMessagesQ &= NULL)
SELF.FreeAssertMsg()
DISPOSE(SELF.AssertMessagesQ)
END
SELF.Clear_Module_Debuger()
IF Verbose > 5 THEN ODS('`Debuger.kill (end) SELF['& ADDRESS(SELF) &']') END
!-----------------------------------------------------------------------------------------!
Debuger.AddUserEvent PROCEDURE(STRING argEventName,LONG argEventEquate)
CODE
IF ~SELF.UserEventNameQ &= NULL
IF SELF.GetUserEvent(argEventEquate)
SELF.UserEventNameQ.EventName = argEventName
PUT(SELF.UserEventNameQ)
ELSE
SELF.UserEventNameQ.EventEquate = argEventEquate
SELF.UserEventNameQ.EventName = argEventName
ADD(SELF.UserEventNameQ)
END
END
!-----------------------------------------------------------------------------------------!
Debuger.GetUserEvent PROCEDURE(LONG argEventEquate)!string
CODE
IF ~SELF.UserEventNameQ &= NULL
SELF.UserEventNameQ.EventEquate = argEventEquate
GET(SELF.UserEventNameQ, SELF.UserEventNameQ.EventEquate)
RETURN CHOOSE( ERRORCODE()=0, SELF.UserEventNameQ.EventName, '')
ELSE
RETURN ''
END
!-----------------------------------------------------------------------------------------!
Debuger.GetEventDescr_WM PROCEDURE(LONG argEvent)!,string !No SELF.OffsetWork, or UserEvents
!todo: received events with missing values:
! 0x007Fh - WM_GETICON
! 0x0215h
! 0x02A2h
! 0x0400h
lcl:Retval LIKE(qtUserEventName.EventName)
qWM_WINDOWPOSCHANGING EQUATE(70) !added Feb/4/05
CODE
CASE argEvent
OF qWM_WINDOWPOSCHANGING; lcl:RetVal = 'WM_WINDOWPOSCHANGING' !had problems with GPFs I assume it has todo with
OF 0219H ; lcl:RetVal = 'WM_DEVICECHANGE'
ELSE debugerNameMessage(lcl:RetVal, argEvent)
END
RETURN lcl:RetVal
!-----------------------------------------------------------------------------------------!
Debuger.GetEventDescr PROCEDURE(LONG argEvent)!,string !prototype set to default to -1
!NameMessage (*cstring, unsigned EventNum ),name('WslDebug$NameMessage'),raw !Note: use Event() + EVENT:FIRST else will get WM_*
lcl:Retval LIKE(qtUserEventName.EventName)
lcl:EventNum UNSIGNED
CODE
IF argEvent = -1
argEvent = EVENT()
END
lcl:RetVal = SELF.GetUserEvent( argEvent )
IF ~lcl:RetVal
CASE argEvent
OF Event:User ; lcl:RetVal = 'EVENT:User'
OF Event:User + 1 TO Event:Last ; lcl:RetVal = 'EVENT:User + '& argEvent - Event:User
OF Event:APP ; lcl:RetVal = 'EVENT:App'
OF Event:APP + 1 TO Event:APP_LAST; lcl:RetVal = 'EVENT:App + ' & argEvent - Event:APP
ELSE ; IF SELF.EventOffset = -2 !indicates could not find a valid offset
lcl:RetVal = 'EVENT['& argEvent &']'
ELSE
lcl:EventNum = argEvent + SELF.EventOffset ! 1400h (pre c6) or A000h (c6) !EVENT:FIRST equate(01400h)/(0A000h)
debugerNameMessage(lcl:RetVal, lcl:EventNum)
END
END
END
RETURN lcl:RetVal ! CLIP(lcl:RetVal)
!-----------------------------------------------------------------------------------------!
Debuger.GetFEQDescr PROCEDURE(SIGNED argFEQ)!,string !prototype set to default to -1
! GetFieldName (signed FEQ ),*cstring,raw,name('Cla$FIELDNAME')
Retval CSTRING(60) !<--- some arbitrary length
lcl:FEQ SIGNED
szRef &CSTRING
CODE
lcl:FEQ = CHOOSE(argFEQ = -MAX:FEQ, FIELD(), argFEQ)
COMPILE('** C55+ **',_C55_)
RetVal = debugerGetFieldName(lcl:FEQ)
!END-COMPILE('** C55+ **',_C55_)
OMIT('** C55+ **',_C55_)
szRef &= debugerGetFieldName(lcl:FEQ)
RetVal = szRef
!END-OMIT('** C55+ **',_C55_)
RETURN RetVal
!-----------------------------------------------------------------------------------------!
Debuger.PrintEvent PROCEDURE(<STRING argHeader>,<BYTE argForceDebug>)
!originally designed to mimic 'WslDebug$PrintEvent')
!'WslDebug$PrintEvent' has output something like: "EVENT:Selected ?BUTTON1 (1)<13,10>"
CODE
SELF.debugout( FORMAT(SELF.GetEventDescr() & CHOOSE(0{prop:AcceptAll}<>1,'', ' - AcceptAll') ,@s30 ) & |
CHOOSE( FIELD()=0 ,'', ' Field('& SELF.GetFEQDescr() & ' ='& FIELD() &')' ) & |
CHOOSE( FOCUS()=0 ,'', ' Focus('& SELF.GetFEQDescr(FOCUS()) & ' ='& FOCUS() &')' ) & |
CHOOSE( SELECTED()=0 ,'', ' Selected('& SELF.GetFEQDescr(SELECTED()) & ' ='& SELECTED() &')' ) & |
CHOOSE( FOCUS(){prop:SelStart}=0 ,'', ' SelStart('& FOCUS(){prop:SelStart} &')' ) & |
CHOOSE( FOCUS(){prop:SelEnd }=0 ,'', ' SelEnd('& FOCUS(){prop:SelEnd} &')' ) & |
CHOOSE( KEYCODE()=0 ,'', ' KeyCode('& KEYCODE() &')' ) & |
CHOOSE( ERRORCODE()=0 ,'', ' Error('& ERRORCODE() &': ' & CLIP(ERROR()) &')' ) & |
' Thread('& THREAD() &')' & |
CHOOSE( CONTENTS(FOCUS())='' ,'', ' Contents('& CONTENTS(FOCUS()) &')' ) & |
CHOOSE(FOCUS(){prop:ScreenText}='' ,'', ' ScreenText('& FOCUS(){prop:ScreenText} &')' ) & |
'', argHeader,,argForceDebug)
!v-- Previous Version --v
! SELF.debugout( FORMAT(SELF.GetEventDescr(),@s30) & | !~Mar/20/08 @s20 -> @s30
! ' Field('& SELF.GetFEQDescr() & ' ='& FIELD() &')' & |
! ' Focus('& SELF.GetFEQDescr(FOCUS()) & ' ='& FOCUS() &')' & |
! ' Selected('& SELF.GetFEQDescr(SELECTED()) & ' ='& SELECTED() &')' & |
! ' SelStart('& FOCUS(){prop:SelStart} &')' & |
! ' SelEnd('& FOCUS(){prop:SelEnd} &')' & |
! ' KeyCode('& KEYCODE() &')' & |
! ' Error('& ERRORCODE() &': ' & CLIP(ERROR()) &')' & |
! ' Thread('& THREAD() &')' & |
! ' Contents('& CONTENTS(FOCUS()) &')' & |
! ' ScreenText('& FOCUS(){prop:ScreenText} &')' & |
! ' AcceptAll('& 0{prop:AcceptAll} &')' & | !+Aug/31/06
! '', argHeader,,argForceDebug)
!simpler version:! SELF.debugout(SELF.GetEventDescr() & '<32>{10}' & SELF.GetFEQDescr() & '<32>{10}('& FIELD() &')', argHeader,,argForceDebug)
RETURN
!-----------------------------------------------------------------------------------------!
Debuger.delayout PROCEDURE(STRING argBody,<STRING argHeader>,BYTE argForceDebug)
PARAM:DEBUGOUT:HEADER EQUATE(3) !omittable parameter number, remember to add 1 for SELF
CODE
IF SELF.debugActive OR argForceDebug
IF NOT SELF.DelayActive
!MG: consider forcing output, when header changes (and is non-null)
IF NOT OMITTED(PARAM:DEBUGOUT:HEADER)
SELF.DelayHeader = argHeader
ELSE SELF.DelayHeader = ''
END
SELF.DelayBody = argBody
SELF.DelayActive = TRUE
ELSE
IF NOT OMITTED(PARAM:DEBUGOUT:HEADER) AND argHeader AND argHeader <> SELF.DelayHeader
!Force output, and start a new delay
SELF.debugout('',SELF.DelayHeader,FALSE,TRUE)
SELF.DelayHeader = argHeader
SELF.DelayBody = argBody
ELSE
SELF.DelayBody = CLIP(SELF.DelayBody) & argBody
END
END
END
!-----------------------------------------------------------------------------------------!
Debuger.Message PROCEDURE(STRING argBody,<STRING argHeader>,BYTE argShowMessage,BYTE argForceDebug) !string body,<string> header,BYTE ShowMessage=FALSE,BYTE ForceDebug=FALSE
PARAM:DEBUGOUT:HEADER EQUATE(3) !omittable parameter number, remember to add 1 for SELF
CODE
IF OMITTED(PARAM:DEBUGOUT:HEADER)
SELF.debugout( argBody, , argShowMessage, argForceDebug)
ELSE
SELF.debugout( argBody, argHeader, argShowMessage, argForceDebug)
END
!-----------------------------------------------------------------------------------------!
Debuger.ODS PROCEDURE(STRING xMessage) !+Mar/13/08
CODE
ODS(SELF.debugfilter & xMessage)
!-----------------------------------------------------------------------------------------!
Debuger.debugout_splitby PROCEDURE(STRING argBody,STRING argSplitBy, <STRING argHeader>,BYTE argShowMessage,BYTE argForceDebug)
!doesn't split within the .delaybody
CurrChar LONG(1)
NextChar LONG
nMax LONG,AUTO
CODE
!IF SELF.DelayActive THEN NextChar = INSTRING( SELF.delaybody, argSplitBy, 1, 1)
!ELSIF ~NextChar THEN NextChar = INSTRING( argbody , argSplitBy, 1, 1)
!END
LOOP
NextChar = INSTRING( argSplitBy, argbody, 1, CurrChar)
IF ~NextChar THEN BREAK END
SELF.DebugOut( argbody[ CurrChar : NextChar - 1],argHeader, argShowMessage, argForceDebug)
CurrChar = NextChar + SIZE(argSplitBy)
END
nMax = LEN(CLIP(argBody))
IF CurrChar <= nMax
SELF.DebugOut( argbody[ CurrChar : nMax ],argHeader, argShowMessage, argForceDebug)
END
!-----------------------------------------------------------------------------------------!
Debuger.debugout PROCEDURE(STRING argBody,<STRING argHeader>,BYTE argShowMessage,BYTE argForceDebug) !string body,<string> header,BYTE ShowMessage=FALSE,BYTE ForceDebug=FALSE
PARAM:DEBUGOUT:HEADER EQUATE(3) !omittable parameter number, remember to add 1 for SELF
!lcl:Altmsg LIKE(SELF.Thismsg) !side-effect argument into ShowMessageWindow
CODE
IF SELF.debugActive OR argForceDebug
IF argShowMessage
SELF.ShowMessageWindow(argBody,argHeader)
END
!consider swapping logic around to give running counts of duplicates in SELF.thismsg
SELF.thismsg = SELF.debugfilter & |
SELF.pgmname & ' - ' & |
CHOOSE(OMITTED(PARAM:DEBUGOUT:HEADER)=TRUE,'',CLIP(argHeader) & ' - ') & |
CHOOSE(SELF.DelayActive=TRUE, CLIP(SELF.delaybody), '') & argBody & |
CHOOSE(SELF.AppendCRLF =FALSE,'','<13,10>')
OutputDebugString (SELF.thismsg) ! send the debug message to the viewer
IF SELF.duplicates <> 0 !MG Policy: only track lastmsg,NumberSame if going to do something with them....
IF SELF.lastmsg <> SELF.thismsg
SELF.lastmsg = SELF.thismsg
SELF.NumberSame = 0
ELSE
SELF.NumberSame += 1
!if SELF.duplicates <> 0 and SELF.NumberSame % SELF.duplicates = 0
IF SELF.NumberSame % SELF.duplicates = 0
SELF.ShowMessageWindow('A series of ' & SELF.NumberSame & ' duplicate debug messages have been issued' & |
| '||' & |
| 'Body ['&argBody &']|' & |
| 'DebugFilter ['& SELF.debugFilter &']|' & |
| 'Program Name ['& SELF.pgmname &']|' & |
| 'header ['& CLIP(argHeader) &'] Omitted?['& OMITTED(PARAM:DEBUGOUT:HEADER) &']|' &|
| 'CRLF Status ['& SELF.AppendCRLF &']|' & |
| 'Delay Status ['& SELF.DelayActive &']|' & |
'Message ['& CLIP(SELF.thismsg) &']',argHeader)
END
END
END
SELF.DelayActive = FALSE
END
!-----------------------------------------------------------------------------------------!
Debuger.ShowMessageWindow PROCEDURE(string argBody, string argHeader)
COMPILE('**32bit**',_width32_)
COMPILE('*debug*',_debug_)
DEBUGER::BUTTONLIST EQUATE('&Continue|&Halt|&Debug')
!END-COMPILE('*debug*',_debug_)
OMIT('*debug*',_debug_)
DEBUGER::BUTTONLIST EQUATE('&Continue|&Halt')
!END-OMIT('*debug*',_debug_)
!END-COMPILE('**32bit**',_width32_)
OMIT('**32bit**',_width32_)
DEBUGER::BUTTONLIST EQUATE('&Continue|&Halt')
!END-OMIT('**32bit**',_width32_)
CODE
IF SELF.ShowMessageWindow_Beep
BEEP(BEEP:SystemExclamation)
END
CASE MESSAGE(argBody,SELF.pgmname & CHOOSE(LEN(CLIP(argHeader))=0,'', ' - ' & argHeader), ICON:Exclamation, DEBUGER::BUTTONLIST)
OF 1; !do nothing ! Name: &OK (Default)
OF 2; SELF.debugout('Program Halted -');HALT() ! Name: &Abort
OF 3; SELF.debugbreak() ! Name: Debug
END !CASE
!-----------------------------------------------------------------------------------------!
Debuger.DebugBreak PROCEDURE ! only for 32 bit...doesnt work in 16 bit mode
CODE
COMPILE('***',_width32_)
IF SELF.Debugactive
debugbreak() ! asm ROUTINE
END
!END-COMPILE('***',_width32_)
!-----------------------------------------------------------------------------------------!
Debuger.Clear_Module_Debuger PROCEDURE
QPtr LONG
CODE
!ODS('`Debuger.Clear_Module_Debuger Start Records(DebugersQ)['& RECORDS(DebugersQ) &'] Curr is NULL?['& CHOOSE( DebugersQ.Debuger &= NULL) &'] SELF['& ADDRESS(SELF) &'] Pointer['& POINTER(DebugersQ) &']')
! LOOP QPtr = RECORDS(DebugersQ) TO 1 BY -1
! GET(DebugersQ,QPtr)
! IF DebugersQ.Debuger &= SELF
! DELETE(DebugersQ)
! GET(DebugersQ,QPtr - 1)
! IF ERRORCODE()
! DebugersQ.Debuger &= NULL
! END
! BREAK
! END
! END
!ODS('`Debuger.Clear_Module_Debuger END Records(DebugersQ)['& RECORDS(DebugersQ) &'] Curr is NULL?['& CHOOSE( DebugersQ.Debuger &= NULL) &'] SELF['& ADDRESS(SELF) &'] Pointer['& POINTER(DebugersQ) &']')
LOOP QPtr = RECORDS(DebugersQ) TO 1 BY -1
GET(DebugersQ,QPtr)
IF DebugersQ.Debuger &= SELF
DELETE(DebugersQ)
BREAK
END
END
IF RECORDS(DebugersQ)
GET(DebugersQ, RECORDS(DebugersQ))
ELSE
DebugersQ.Debuger &= NULL
END
!-----------------------------------------------------------------------------------------!
Debuger.Set_Module_Debuger PROCEDURE
QPtr LONG,AUTO
CODE
!module_Debuger &= SELF !Note: can be confusing if there are multiple instances of debugers
!as an ASSERT(0,eqDBG&'yada') can show the wrong prefix,
!this is becauase the module debuger is set to the most recently instantiated debuger
!consider adding protections against adding more than once
LOOP QPtr = RECORDS(DebugersQ) TO 1 BY -1
GET(DebugersQ,QPtr)
IF DebugersQ.Debuger &= SELF
!ODS('`Debuger.Set_Module_Debuger -- returning, SELF already present Records(DebugersQ)['& RECORDS(DebugersQ) &'] SELF['& ADDRESS(SELF) &'] Pointer['& POINTER(DebugersQ) &']')
RETURN
END
END
DebugersQ.Debuger &= SELF
ADD(DebugersQ)
!ODS('`Debuger.Set_Module_Debuger pgmname['& SELF.pgmname &'] Records(DebugersQ)['& RECORDS(DebugersQ) &'] SELF['& ADDRESS(SELF) &'] Pointer['& POINTER(DebugersQ) &']')
!-----------------------------------------------------------------------------------------!
Debuger.Set_AssertHook2 PROCEDURE
CODE
!SELF.DebugOut('Debuger.Set_AssertHook2 MyAssertHook2['& ADDRESS(MyAssertHook2) &']')
SYSTEM{prop:asserthook2} = ADDRESS(MyAssertHook2)
!SELF.DebugOut('Debuger.Set_AssertHook2 MyAssertHook2['& ADDRESS(MyAssertHook2) &']')
!-----------------------------------------------------------------------------------------!
Debuger.FreeAssertMsg PROCEDURE()
QPtr LONG
CODE
IF ~(SELF.AssertMessagesQ &= NULL)
LOOP QPtr = RECORDS(SELF.AssertMessagesQ) TO 1 BY -1
GET (SELF.AssertMessagesQ,QPtr)
DISPOSE(SELF.AssertMessagesQ.szMSG)
DELETE (SELF.AssertMessagesQ)
END
END
!-----------------------------------------------------------------------------------------!
Debuger.DelAssertMsg PROCEDURE(STRING argMessage)
CODE
SELF.AssertMessagesQ.szMSG = CLIP(argMessage) !clip prob. unneeded
GET(SELF.AssertMessagesQ, SELF.AssertMessagesQ.szMSG)
IF ~ERRORCODE()
DISPOSE(SELF.AssertMessagesQ.szMSG)
DELETE (SELF.AssertMessagesQ)
END
!-----------------------------------------------------------------------------------------!
Debuger.AddAssertMsg PROCEDURE(LONG argPriority, STRING argMessage, LONG argAction, LONG argMatchMode) !added Aug,7 2005!
!see LRM for MATCH
!MATCH:* equates are found in Equates.clw
!NOTE: consider adding MATCH:NOCASE to your argMatchMode
!NOTE: I believe the following are identical
! dbg.AddAssertMsg(0,'You are calling CLOSE(*) instead of FileManager.Close()' ,AssertMsgAction::IGNORE,Match:Wild + MATCH:NoCase)
! dbg.AddAssertMsg(0,'You are calling CLOSE(.*) instead of FileManager\.Close()' ,AssertMsgAction::IGNORE,Match:Regular + MATCH:NoCase)
CODE
SELF.AssertMessagesQ.Priority = argPriority
SELF.AssertMessagesQ.szMSG &= NEW CSTRING(LEN(CLIP(argMessage)) + 1)
SELF.AssertMessagesQ.szMSG = CLIP(argMessage)
! SELF.DebugOut('Debuger.AddAssertMsg SELF.AssertMessagesQ.szMSG['& SELF.AssertMessagesQ.szMSG &'] CLIP(argMessage)['& CLIP(argMessage) &'] SELF.AssertMessagesQ.MatchMode['& SELF.AssertMessagesQ.MatchMode &'] Action['& SELF.AssertMessagesQ.Action &']')
! SELF.AssertMessagesQ.szMSG = argMessage
! SELF.DebugOut('Debuger.AddAssertMsg SELF.AssertMessagesQ.szMSG['& SELF.AssertMessagesQ.szMSG &'] CLIP(argMessage)['& CLIP(argMessage) &'] SELF.AssertMessagesQ.MatchMode['& SELF.AssertMessagesQ.MatchMode &'] Action['& SELF.AssertMessagesQ.Action &']')
SELF.AssertMessagesQ.Action = argAction
SELF.AssertMessagesQ.MatchMode = argMatchMode
ADD(SELF.AssertMessagesQ,-SELF.AssertMessagesQ.Priority) !higher numbers go first
!-----------------------------------------------------------------------------------------!
Debuger.MatchAssertMsg PROCEDURE(UNSIGNED LineNumber, STRING filename, STRING argMSG) !added Aug,7 2005!
N LONG
CODE
IF ~(SELF.AssertMessagesQ &= NULL)
SELF.DebugOut('Debuger.MatchAssertMsg, RECORDS(SELF.AssertMessagesQ)['& RECORDS(SELF.AssertMessagesQ) &'] argMSG['& argMSG &']')
LOOP N = 1 TO RECORDS(SELF.AssertMessagesQ)
GET(SELF.AssertMessagesQ,N)
SELF.DebugOut('Debuger.MatchAssertMsg N['& N &'] SELF.AssertMessagesQ.szMSG['& SELF.AssertMessagesQ.szMSG &'] SELF.AssertMessagesQ.MatchMode['& SELF.AssertMessagesQ.MatchMode &'] Action['& SELF.AssertMessagesQ.Action &']')
IF MATCH(argMSG, SELF.AssertMessagesQ.szMSG , SELF.AssertMessagesQ.MatchMode)
RETURN SELF.AssertMessagesQ.Action
END
END
END
SELF.DebugOut('Debuger.MatchAssertMsg NO MATCH')
CLEAR(SELF.AssertMessagesQ)
RETURN AssertMsgAction::NOMATCH
!-----------------------------------------------------------------------------------------!
Debuger.AssertHookAction PROCEDURE(LONG Action, UNSIGNED LineNumber, STRING filename, STRING argMSG) !,LONG,VIRTUAL !added Aug,8 2005!
CODE
IF Action=AssertMsgAction::PrintEvent
SELF.PrintEvent('in['& CLIP(filename) &' @'& LineNumber &'] '& argMSG )
RETURN 1
END
RETURN 0
!-----------------------------------------------------------------------------------------!
Debuger.DescribeAction PROCEDURE(LONG Action) !string
CODE
CASE Action
OF AssertMsgAction::NOMATCH ; RETURN 'NoMatch'
OF AssertMsgAction::IGNORE ; RETURN 'Ignore'
OF AssertMsgAction::PROMPT ; RETURN 'Prompt'
OF AssertMsgAction::AUTOGPF ; RETURN 'AutoGPF'
OF AssertMsgAction::PrintEvent; RETURN 'PrintEvent'
ELSE ; RETURN 'UNKNOWN!'
END
!================================================================
! The DumpQueue Source Was Copied from
! "Debugging Queues with Excel" by Alan Telford
! http://www.clarionmag.com/cmag/v5/v5n02debugq.html
! Some changes have been made
!================================================================
!-----------------------------------------------------------------------------------------!
Debuger.DumpQue PROCEDURE (STRING argheader, QUEUE argQ, <STRING argFilename>, <STRING argFormat>, <LONG arglimit>, <BYTE argforce>) !,String ,Proc ! Declare Procedure
OMITTED::FileName EQUATE(4)
!Updated: by Mark Goldberg Dec/22/04
! added argfileName = 'NOFILE' logic to suppress ascii export
! added SaveQState/RestoreQState logic
! added Format entries of 'X' to suppress a given field
! rewrote DumpQue::LoadPictureFormatQ_Rtn to use INSTRING
! added '/Clip=on'
! by Mark Goldberg Aug/31/06
! fixed a leak when DumpQue:ProcedureReturn was called early, but after DumpQ::SaveQState had been called
! by Mark Goldberg Oct/27/09 -- fixed argForce when SELF.debugactive false (passed argForce on to .DebugOut
!Todo: replace ASCII driver with DOS driver or undocumented RTL commands
! consider adding conditional equates around the ASCII file work
! create an alternate form of format, where fields are explicitly requested vs. excluded
!WARNING: be aware of numeric pictures that add commas -- when working with the ASCII file
eMaxLineLength EQUATE(4096)
N_ExportQFile CSTRING(FILE:MaxFilePath),STATIC
! -> c6 command: PRAGMA('project(#pragma link(C%V%ASC%X%%L%.LIB))'
! If you use DRIVER('ASCII','/TAB=-100') and add a tab ('<9>') as separator between the queue fields and give the filename the extension .xls you can open it in Excel without any effort.
ExportQFile FILE,DRIVER('ASCII','/CLIP = on'),CREATE,NAME(N_ExportQFile)
RECORD RECORD
LINE STRING(eMaxLineLength)
END
END
FieldCnt LONG
Line CSTRING(eMaxLineLength+1)
LinePrefix CSTRING( 20) !'Rec['& r:Ndx &'] ' where max r:Ndx = RECORDS(ArgQ)
RetVal CSTRING(500)
FormatQ QUEUE ! Queue which stores picture formats used when exporting data
Pic CSTRING(31) !changed to cString May/10/05 so can avoid CLIP()ing
END
UseFile BYTE !added Dec/22/04 MG
UseSelf BYTE !added Dec/23/04 MG Flag indicates if SELF.debugout will be called
Hold:QBuffer &STRING
Hold:QPtr LONG
FnameOmitted BYTE
DQ_Assert BYTE(TRUE) !used in Assert, True means off
CODE
IF SUB(argFormat,1,1)='D' THEN DQ_Assert=FALSE; argFormat=SUB(argFormat,2,LEN(argFormat)) END !added MG May/10/05
UseSelf = CHOOSE( SELF.debugactive OR argforce) !fixed MG Dec/24/04 - was backwards
ODS(SELF.debugfilter & 'Debuger.DumpQue UseSelf['& UseSelf &'] SELF.debugactive['& SELF.debugactive &'] argforce['& argforce &']')
FnameOmitted = CHOOSE( OMITTED(OMITTED::FileName) OR argFileName='')
IF FnameOmitted
UseFile = CHOOSE( SELF.dumpQue_AsciiByDefault <> DEBUGER::ASCII_NEVER AND |
UPPER(SELF.dumpQue_DefaultFileName) <> DEBUGER::DUMPQUE_NOFILE |
)
ELSE UseFile = CHOOSE( UPPER(argFileName) <> DEBUGER::DUMPQUE_NOFILE )
END
!ASSERT(0,eqDBG&'UseFile['& UseFile &'] FnameOmitted['& FnameOmitted &'] argFileName['& argFileName &'] Default['& SELF.dumpQue_DefaultFileName &']')
!! -- how detect an &= NULL, when we're not working with a reference ?
!! if not Address(argQ)
!! Assert(0,eqDBG&'Debuger DumpQue - an invalid Queue was given - returning')
!! UseSelf = FALSE
!! RetVal = 'Invalid Queue Given'
!! end
IF ~UseSelf AND ~UseFile
ODS(SELF.debugfilter & 'Debuger.DumpQue Early Return')
RetVal = 'no output requested'
DO DumpQue::ProcedureReturn
END
ODS('Debuger.DumpQue argFormat['& argFormat &']')
! ; ASSERT(0,eqDBG&'DumpQue')
DO DumpQue::SaveQState ! ; ASSERT(0,eqDBG&'DumpQue')
DO DumpQue::CreateFile_Rtn ! ; ASSERT(0,eqDBG&'DumpQue')
DO DumpQue::CountFieldsInQueue_Rtn ! ; ASSERT(0,eqDBG&'DumpQue')
DO DumpQue::LoadPictureFormatQ_Rtn ! ; ASSERT(0,eqDBG&'DumpQue')
DO DumpQue::WriteQueueHeader_Rtn ! ; ASSERT(0,eqDBG&'DumpQue')
DO DumpQue::WriteQueueRecords_Rtn ! ; ASSERT(0,eqDBG&'DumpQue')
!DO DumpQue::RestoreQState ! ; ASSERT(0,eqDBG&'DumpQue') !moved Aug/31/06, to ProcedureReturn
IF UseFile
CLOSE(ExportQFile)
END
RetVal = ''
DO DumpQue::ProcedureReturn
!------------------------------------------------------------------
DumpQue::ProcedureReturn ROUTINE
IF UseSelf
SELF.DebugOut('DumpQ - ' & LinePrefix & argheader & ' - RetVal['& retval &']',,,argforce)
SELF.DebugOut('DumpQ - ' & LinePrefix & '={42}',,,argforce)
END
IF NOT (Hold:QBuffer &= NULL) !+ Aug/31/06
DO DumpQue::RestoreQState !+ Aug/31/06
END !+ Aug/31/06
RETURN retval
!------------------------------------------------------------------
DumpQue::SaveQState ROUTINE
Hold:QBuffer &= NEW STRING( SIZE(argQ))
! ODS('Dubugger.DumpQue::SaveQState ADDRESS(Hold:QBuffer)['& ADDRESS(Hold:QBuffer) &']')
Hold:QBuffer = argQ
Hold:QPtr = POINTER(argQ)
!------------------------------------------------------------------
DumpQue::RestoreQState ROUTINE
GET(argQ,Hold:QPtr)
argQ = Hold:QBuffer
! ODS('Dubugger.DumpQue::RestoreQState ADDRESS(Hold:QBuffer)['& ADDRESS(Hold:QBuffer) &']')
DISPOSE(Hold:QBuffer)
!------------------------------------------------------------------
DumpQue::CreateFile_Rtn ROUTINE
IF ~RECORDS(argQ)
RetVal = 'Queue is empty. No export file produced.'
DO DumpQue::ProcedureReturn
END
IF UseFile
IF FnameOmitted OR UPPER(CLIP(argFileName)) = DEBUGER::DUMPQUE_PROMPT
N_ExportQFile = SELF.dumpQue_DefaultFileName
IF SELF.dumpQue_AsciiByDefault = DEBUGER::ASCII_PROMPT
! prompt for a filename if not already provided
IF ~FILEDIALOG('Export Queue to file ...', N_ExportQFile, 'CSV files (*.csv)|*.csv', FILE:SAVE + FILE:KEEPDIR + FILE:LONGNAME) !10011b)
RetVal = 'No export file selected from FileDialog'
DO DumpQue::ProcedureReturn
END
END
ELSE
N_ExportQFile = argFileName
END
CREATE(ExportQFile)
IF ~ERRORCODE()
OPEN (ExportQFile, FileAccessMode:Default)
END
IF ERRORCODE()
RetVal = 'No export file produced.|Error: '&CLIP(ERRORCODE()) & ' ' & CLIP(ERROR())
DO DumpQue::ProcedureReturn
END
IF UseSelf
SELF.debugout('DumpQ File created - ' & N_ExportQfile,argheader,,argforce)
END
END
!------------------------------------------------------------------
DumpQue::CountFieldsInQueue_Rtn ROUTINE
!| Count the number of fields in the queue, and store in FIELDCNT
!| Todo - make this a generic exposed method
DATA
r:Any ANY
CODE
FieldCnt = 0
LOOP
r:Any &= WHAT(argQ, FieldCnt+1)
IF r:Any &= NULL THEN BREAK END
FieldCnt += 1
END
!ASSERT(DQ_Assert,eqDBG&'FieldCnt['& FieldCnt &']')
!------------------------------------------------------------------
DumpQue::LoadPictureFormatQ_Rtn ROUTINE
!| If an optional argFORMAT string exists, then parse this string (using | as delimiter)
!| and store it in FORMATQ to be used when writing out to file.
DATA
r:Pos LONG
r:NextPos LONG
r:Ndx LONG
r:Len LONG
CODE
!Note: in C6 could use IsGroup() logic to help avoid some problems... (should really be done when building the FormatQ) -- could use the Header instead (prepend with a space...)
IF argFormat <> ''
r:Pos = 1
r:Len = LEN(argformat)
LOOP r:Ndx = 1 TO FieldCnt
IF r:Pos > r:Len THEN BREAK END
r:NextPos = INSTRING('|',argFormat,1,r:Pos)
IF ~r:NextPos
r:NextPos = r:Len + 1
FormatQ.Pic = '' !changed June/3/05
ELSE
FormatQ.Pic = argFormat[ r:Pos : r:NextPos - 1]
END
ADD(FormatQ)
r:Pos = r:NextPos + 1
END
END
! !---- self debugging ----!
! SELF.DebugOut('DumpQue::LoadPictureFormatQ_Rtn FormatQ FieldCnt['& FieldCnt &'] Format['& argFormat &']')
! LOOP r:Ndx = 1 TO RECORDS(FormatQ)
! GET(FormatQ, r:NDX)
! SELF.DebugOut('FormatQ ['& r:NDX &'] Pic['& CLIP(FormatQ.Pic) &'] is null['& CHOOSE( FormatQ.Pic = '') &']')
! end
! !---- self debugging ----! -end
!------------------------------------------------------------------
DumpQue::WriteQueueHeader_Rtn ROUTINE
!| Write a header line to export file, with the NAMES of each column
DATA
r:Ndx LONG
r:Comma CSTRING(2) !no auto
r:Quote CSTRING('"')
COMPILE('**++** _C61_Plus_',_C61_)
r:DimCount LONG
!END-COMPILE('**++** _C61_Plus_',_C61_)
CODE
IF UseSelf
SELF.DebugOut('DumpQ - ' & LinePrefix & '={42}',,,argforce)
SELF.DebugOut('DumpQ - ' & LinePrefix & argHeader,,,argforce )
r:Quote = ''
END
Line = '' ! ; ASSERT(0,eqDBG&'DumpQue')
LOOP r:Ndx = 1 TO FieldCnt
GET(FormatQ, r:Ndx)
IF ~ERRORCODE() AND FormatQ.Pic <> '' AND FormatQ.Pic[1]='X' THEN CYCLE END !added MG Dec/24/04
!Line = Line & CHOOSE(~Line,'', ',') & '"' & CLIP(WHO(argQ, r:Ndx)) & '"'
OMIT('**++** _C61_Plus_',_C61_)
Line = Line & r:Comma & r:Quote & CLIP(WHO(argQ, r:Ndx)) & r:Quote
r:Comma = ','
!END-OMIT('**++** _C61_Plus_',_C61_)
COMPILE('**++** _C61_Plus_',_C61_)
IF HOWMANY(argQ,r:Ndx) = 1
Line = Line & r:Comma & r:Quote & CLIP(WHO(argQ, r:Ndx)) & r:Quote
r:Comma = ','
ELSE
LOOP r:DimCount = 1 to HOWMANY(argQ,r:Ndx)
Line = Line & r:Comma & r:Quote & CLIP(WHO(argQ, r:Ndx)) & '['& r:DimCount &']' & r:Quote
r:Comma = ','
END
END
!END-COMPILE('**++** _C61_Plus_',_C61_)
!ODS(SELF.DebugFilter & 'DumpQ Field['& r:NDX &'] WHO['& CLIP(WHO(argQ, r:NDX)) &'] Type['& SELF.GetVarType( WHAT(argQ, r:Ndx) ) &']=['& SELF.DescribeDataType( SELF.GetVarType( WHAT(argQ, r:Ndx) ) )&']<13,10>')
! ; ASSERT(0,eqDBG&'DumpQue r:Ndx['& r:Ndx &']')
END
DO DumpQue::WriteLine! ; ASSERT(0,eqDBG&'DumpQue')
!------------------------------------------------------------------
DumpQue::WriteLine ROUTINE
IF UseSelf
SELF.DebugOut('DumpQ - ' & LinePrefix & Line,,,argforce )
END
IF UseFile
ExportQFile.Line = Line
ADD(ExportQFile)
END
!------------------------------------------------------------------
DumpQue::WriteQueueRecords_Rtn ROUTINE