-
Notifications
You must be signed in to change notification settings - Fork 5
/
decodepc.sqr
1720 lines (1546 loc) · 48.8 KB
/
decodepc.sqr
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
!*******************************************************************************
! Program: DECODEPC.SQR
! Url: https://github.com/dlprice/Decode-PeopleCode
!*******************************************************************************
!
! Programmer: David L. Price
!
!*******************************************************************************
!
! This program was designed as a learning experiment to help me understand
! better how PeopleSoft stored PeopleCode.
!
! TO DO / KNOWN ISSUES:
! * Indenting is still a work in progress
! * There are still several instances where line feeds aren't correct. Such
! as where semi-colons are options (single statement 'if' blocks)
! * Spacing is fairly good. Semi-colons sometimes get an extra space before them.
!
!*******************************************************************************
! SQR Modification Log
!
! DATE DESCRIPTION
! ========== ================================================================
! 12-04-2004 Created for PeopleSoft 8.4x
! 03-14-2005 Added Interactive selection mode. Enter 'I' at prompt
! 01-23-2006 Added additional command codes. Fixed break when bad /missing
! PC is submitted.
! 08-30-2006 Added 'legacy number' command code. Still needs work.
! 02-03-2010 Added block comment (0x55) and continue command (0x6e)
! 03-11-2011 Added about 9 commands, mostly used in Application Packages.
! Made changes to the evaluate to handle the large number of breaks.
! Updated Legacy Number logic to better handle decimals.
! 06-15-2011 Updated Comment commands to handle longs comments (by calling
! LineFeed whe n 0x0a is encountered), added new commands
! 09-20-2011 Fixed a bunch of stupid spelling mistakes (mostly in comments)
! 10-01-2011 Minor improvements to indention.
! Removed <brk>.
! Remove prompting and interactive sessions to optimize writing
! several PeopleCode objects to file in a row. You now need to
! modify the WHERE clause to adjust output.
! Added ability to skip writing file if it already exists (on by default)
! Added some additional commands found in 8.51 (implements)
! Strips invalid characters from filename
! 11-04-2011 Changes to indention logic.
! Added two more commands per user request: 0x70 (interface) & 0x71 (end-interface)
! Added 0x6c (Data Type)
! 03-13-2012 8.52 changed PSPCMPROG from a LONG RAW to a BLOB. Need to remove
! function to convert LONG RAW to BLOB.
! 06-21-2013 Removed dependency on DLP_PCODE table. CLOBs are much easier to
! work with than LONG RAW. Probably will break all backward
! compatibility. Min PeopleTools version likely: 8.52
! 07-18-2014 Added 0x52 (Doc) command
!
!*******************************************************************************
#define TRUE 1
#define FALSE 0
#define SLICE_SIZE 2000 ! 2000 seems to be the maximum for ORACLE
#define INDENT_SIZE 3
#define MAX_OPTIONS 20
!*******************************************************************************
begin-program
!*******************************************************************************
move 'DECODEPC' to $ReportID
move 'PeopleCode Decoder' to $ReportTitle
do Init-Report
! Initialize Settings
let #Output_To_File = {TRUE}
let #Skip_If_Exists = {TRUE}
let $Output_Directory = 'c:\temp\stage\'
begin-select distinct
OBJECTVALUE1
OBJECTVALUE2
OBJECTVALUE3
OBJECTVALUE4
OBJECTVALUE5
OBJECTVALUE6
OBJECTVALUE7
let $WhereClause = 'OBJECTVALUE1 = ''' || &ObjectValue1 || ''' and ' ||
'OBJECTVALUE2 = ''' || &ObjectValue2 || ''' and ' ||
'OBJECTVALUE3 = ''' || &ObjectValue3 || ''' and ' ||
'OBJECTVALUE4 = ''' || &ObjectValue4 || ''' and ' ||
'OBJECTVALUE5 = ''' || &ObjectValue5 || ''' and ' ||
'OBJECTVALUE6 = ''' || &ObjectValue6 || ''' and ' ||
'OBJECTVALUE7 = ''' || &ObjectValue7 || ''''
let $ObjectName = rtrim(&ObjectValue1 || '.' ||
&ObjectValue2 || '.' ||
&ObjectValue3 || '.' ||
&ObjectValue4 || '.' ||
&ObjectValue5 || '.' ||
&ObjectValue6 || '.' ||
&ObjectValue7 , '. ')
let #EndOfCode = {FALSE}
let $CodeLine = ''
let $Code = ''
let $Indent = '' ! +: Add one level, -: Remove one level, 0: Reset to zero
let #Indent = 0
if #Output_To_File
do Open-File
end-if
if not (#Output_To_File and #Skip_File)
let #Program_Segment = 0
let #Program_Slice = -1
! Get rid of first 37 bytes. PeopleCode header information.
! We might do something with this later.
let #i = 0
while #i < 37
do NextByte(#tVal)
! show #tVal edit 099 noline
! show ' ' noline
add 1 to #i
end-while
! Program starts at byte 38
do NextByte(#tVal)
while not #end-file
let $SBefore = 'N'
!let $SAfter = 'N'
! 'Y' - Space Required
! 'N' - Space Not Required
! 'P' - Space Required, except next to punctuation: ().,;
do Evaluate-Return-Value
if #EndOfCode
break
end-if
do NextByte(#tVal)
end-while
do LineFeed
else
show ' - Skipped'
end-if
if #Output_To_File and not #Skip_File
close 1
end-if
from pspcmprog
where lastupdoprid <> 'PPLSOFT' ! All custom or customized PeopleCode
order by 1,2,3,4,5,6,7
end-select
end-program
!*******************************************************************************
begin-procedure Init-Report
!*******************************************************************************
do Get-Tools-Version($ToolsRel)
do Get-Database-Name($DBName)
show '------------------------------------------------------------------------'
show $ReportTitle
show 'Tools: ' $ToolsRel
show 'Database: ' $DBName
show '------------------------------------------------------------------------'
show ' '
date-time () MM/DD/YYYY &ReportDate
date-time () HH:MI &ReportTime
create-array name=Options size={MAX_OPTIONS}
field=Option:char
create-array name=WhereClause size=16
field=Item:char
evaluate $sqr-database
when = 'ORACLE'
let $Today = 'SYSDATE'
begin-sql
ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-YYYY';
ALTER SESSION SET NLS_DATE_LANGUAGE='AMERICAN';
end-sql
break
when-other
show ' '
show '= = = = = = = = = E R R O R = = = = = = = = ='
show ' '
show 'Sorry. Decode PeopleCode currently'
show 'only works on Oracle.'
show ' '
show '= = = = = = = = = = = = = = = = = = = = = = ='
stop quiet
end-evaluate
end-procedure
!*******************************************************************************
begin-procedure Open-File
!*******************************************************************************
! The record length needs to be longer than just a line since comments are stored
! with built in linefeeds (0x0a). I suppose I could have called LineFeed when
! these were encountered. Which, by the way, I finally did in 2011.
let #Skip_File = {FALSE}
let $FileName = nvl($ObjectName,'peoplecode') || '.pc'
let $FileName = $Output_Directory || nvl(translate($ObjectName,'?','_'),'peoplecode') || '.pc'
show 'Output to: ' $FileName
if #Skip_If_Exists and exists($FileName) = 0
let #Skip_File = {TRUE}
else
open $FileName as 1
for-writing
record=10000:vary
status=#Open_Error
if #Open_Error
show ' '
show ' *** Unable to open filename ***'
show ' '
stop
end-if
end-if
end-procedure
!*******************************************************************************
begin-procedure Evaluate-Return-Value
!*******************************************************************************
! This list is not conclusive. There are still gaps. I can only assume
! that every number has a meaning... but some of these could be for obsolete
! commands and so no longer used. Currently the program will stop when it
! encounters an unrecognized code.
! Currently the pssqr.ini file delivered by PeopleSoft only allows for 75 breaks.
! This, of course, could be increased, but to keep this as universally usable as
! possible, I am breaking up the evaluate.
if #tVal <= 60
evaluate #tVal
when = 1 ! 0x01
! Variable Name
let $SBefore = 'P'
do Get-String($tString)
do WriteCode($tString)
let $SAfter = 'P'
break
when = 3 ! 0x03
let $SBefore = 'N'
do WriteCode(',')
let $SAfter = 'Y'
break
when = 4 ! 0x04
let $SBefore = 'Y'
do WriteCode('/')
let $SAfter = 'Y'
break
when = 5 ! 0x05
let $SBefore = 'N'
do WriteCode('.')
let $SAfter = 'N'
break
when = 6 ! 0x06
let $SBefore = 'Y'
do WriteCode('=')
let $SAfter = 'Y'
break
when = 7 ! 0x07
! End of Code
let #EndOfCode = {TRUE}
break
when = 8 ! 0x08
let $SBefore = 'Y'
do WriteCode('>=')
let $SAfter = 'Y'
break
when = 9 ! 0x09
let $SBefore = 'Y'
do WriteCode('>')
let $SAfter = 'Y'
break
when = 10 ! 0x0a
! Function / Method / External Datatype / Class Name
let $SBefore = 'P'
do Get-String($tString)
do WriteCode($tString)
let $SAfter = 'P'
break
when = 11 ! 0x0b
let $SBefore = 'N'
do WriteCode('(')
let $SAfter = 'N'
break
when = 12 ! 0x0c
let $SBefore = 'Y'
do WriteCode('<=')
let $SAfter = 'Y'
break
when = 13 ! 0x0d
let $SBefore = 'Y'
do WriteCode('<')
let $SAfter = 'Y'
break
when = 14 ! 0x0e
let $SBefore = 'Y'
do WriteCode('-')
let $SAfter = 'Y'
break
when = 15 ! 0x0f
let $SBefore = 'Y'
do WriteCode('*')
let $SAfter = 'Y'
break
when = 16 ! 0x10
let $SBefore = 'Y'
do WriteCode('<>')
let $SAfter = 'Y'
break
when = 17 ! 0x11
! Number (Legacy? no longer used?)
let $SBefore = 'P'
do Get-Legacy-Number($tVal)
do WriteCode($tVal)
let $SAfter = 'P'
break
when = 18 ! 0x12
! System Variable Name
let $SBefore = 'P'
do Get-String($tString)
do WriteCode($tString)
let $SAfter = 'P'
break
when = 19 ! 0x13
let $SBefore = 'Y'
do WriteCode('+')
let $SAfter = 'Y'
break
when = 20 ! 0x14
let $SBefore = 'N'
do WriteCode(')')
let $SAfter = 'N'
break
when = 21 ! 0x15
let $SBefore = 'N'
do WriteCode(';')
do LineFeed
let $SAfter = 'N'
break
when = 22 ! 0x16
! Quoted Literal
let $SBefore = 'P'
do Get-String($tString)
let $tString = '"' || $tString || '"'
do WriteCode($tString)
let $SAfter = 'P'
break
when = 24 ! 0x18
let $SBefore = 'Y'
do WriteCode('And')
do LineFeed
let $SAfter = 'Y'
break
when = 25 ! 0x19
let $SBefore = 'Y'
do SetIndent('-+')
do WriteCode('Else')
do LineFeed
let $SAfter = 'Y'
break
when = 26 ! 0x1a
let $SBefore = 'Y'
do SetIndent('-')
do WriteCode('End-If')
let $SAfter = 'P'
!do LineFeed ! Should have a semi-colon and not require a linefeed
break
when = 27 ! 0x1b
let $SBefore = 'Y'
do WriteCode('Error')
let $SAfter = 'Y'
break
when = 28 ! 0x1c
let $SBefore = 'Y'
do SetIndent('+')
do WriteCode('If')
let $SAfter = 'Y'
break
when = 29 ! 0x1d
let $SBefore = 'Y'
do WriteCode('Not')
let $SAfter = 'Y'
break
when = 30 ! 0x1e
let $SBefore = 'Y'
do WriteCode('Or')
do LineFeed
let $SAfter = 'Y'
break
when = 31 ! 0x1f
let $SBefore = 'Y'
do WriteCode('Then')
do LineFeed
let $SAfter = 'Y'
break
when = 32 ! 0x20
let $SBefore = 'Y'
do WriteCode('Warning')
let $SAfter = 'Y'
break
when = 33 ! 0x21
! PeopleSoft object indicator (w/ Object name)
let $SBefore = 'P'
do NextByte(#Byte1)
do NextByte(#Byte2) ! could be the high order byte of NAMENUM
do Get-Object-Reference(#Byte1,$Recname, $Refname)
let $out = $Recname || '.' || $Refname
do WriteCode($out)
let $SAfter = 'P'
break
when = 35 ! 0x23
let $SBefore = 'Y'
do WriteCode('|')
let $SAfter = 'Y'
break
when = 36 ! 0x24
! Comment
do NextByte(#lCommentLength1)
do NextByte(#lCommentLength2)
let #lCommentLength = (#lCommentLength2 * 256) + #lCommentLength1
let #i = 0
while #i < #lCommentLength
do NextByte(#tVal)
if #tVal = 10
do LineFeed
else
let $out = chr(#tVal)
do WriteCode($out)
end-if
do NextByte(#tVal)
add 2 to #i
end-while
do LineFeed
break
when = 37 ! 0x25
let $SBefore = 'Y'
do SetIndent('+')
do WriteCode('While')
let $SAfter = 'Y'
break
when = 38 ! 0x26
let $SBefore = 'Y'
do SetIndent('-')
do WriteCode('End-While')
let $SAfter = 'Y'
break
when = 39 ! 0x27
let $SBefore = 'Y'
do SetIndent('+')
do WriteCode('Repeat')
do LineFeed
let $SAfter = 'Y'
break
when = 40 ! 0x28
let $SBefore = 'Y'
do SetIndent('-')
do WriteCode('Until')
let $SAfter = 'Y'
break
when = 41 ! 0x29
let $SBefore = 'Y'
do SetIndent('+')
do WriteCode('For')
let $SAfter = 'Y'
break
when = 42 ! 0x2a
let $SBefore = 'Y'
do WriteCode('To')
let $SAfter = 'Y'
break
when = 43 ! 0x2b
let $SBefore = 'Y'
do WriteCode('Step')
let $SAfter = 'Y'
break
when = 44
let $SBefore = 'Y'
do SetIndent('-')
do WriteCode('End-For')
let $SAfter = 'Y'
break
when = 45 ! 0x2d
! Code Section Separator. Not sure exactly what this is for,
! so I am writing it out to maybe be able to spot a pattern
! do WriteCode('<brk>')
! do WriteCode('=====================================================================================')
do LineFeed
break
when = 46 ! 0x2e
let $SBefore = 'Y'
do WriteCode('Break')
let $SAfter = 'Y'
break
when = 47 ! 0x2f
let $SBefore = 'Y'
do WriteCode('True')
let $SAfter = 'Y'
break
when = 48 ! 0x30
let $SBefore = 'Y'
do WriteCode('False')
let $SAfter = 'Y'
break
when = 49 ! 0x31
do SetIndent('0')
let $SBefore = 'Y'
do WriteCode('Declare')
let $SAfter = 'Y'
break
when = 50 ! 0x32
let $SBefore = 'Y'
do SetIndent('+')
do WriteCode('Function')
let $SAfter = 'Y'
break
when = 51 ! 0x33
let $SBefore = 'Y'
do WriteCode('Library')
let $SAfter = 'Y'
break
when = 53 ! 0x35
let $SBefore = 'Y'
do WriteCode('As')
let $SAfter = 'Y'
break
when = 54 ! 0x36
let $SBefore = 'Y'
do WriteCode('Value')
let $SAfter = 'Y'
break
when = 55 ! 0x37
let $SBefore = 'Y'
do SetIndent('-')
do WriteCode('End-Function')
let $SAfter = 'P'
break
when = 56 ! 0x38
let $SBefore = 'Y'
do WriteCode('Return')
let $SAfter = 'Y'
break
when = 57 ! 0x39
let $SBefore = 'Y'
do WriteCode('Returns')
let $SAfter = 'Y'
break
when = 58 ! 0x3a
let $SBefore = 'Y'
do WriteCode('PeopleCode')
let $SAfter = 'Y'
break
when = 59 ! 0x3b
let $SBefore = 'Y'
do WriteCode('Ref')
let $SAfter = 'Y'
break
when = 60 ! 0x3c
let $SBefore = 'Y'
do WriteCode('Evaluate')
let $SAfter = 'Y'
break
when-other
show ''
show '**************'
show 'CodeLine: ' $Codeline
show 'Unknown:' #tVal
stop
break
end-evaluate
else ! #tVal >= 61
evaluate #tVal
when = 61 ! 0x3d
let $SBefore = 'Y'
do WriteCode('When')
let $SAfter = 'Y'
break
when = 62 ! 0x3e
let $SBefore = 'Y'
do WriteCode('When-Other')
let $SAfter = 'Y'
break
when = 63 ! 0x3f
let $SBefore = 'Y'
do WriteCode('End-Evaluate')
let $SAfter = 'Y'
break
when = 64 ! 0x40
! PeopleCode Variable Type Name
let $SBefore = 'P'
do Get-String($tString)
do WriteCode($tString)
let $SAfter = 'P'
break
when = 65 ! 0x41
! Parmlist
break
when = 66 ! 0x42
! End Parmlist / End of Declare Statement
break
when = 67 ! 0x43
let $SBefore = 'Y'
do WriteCode('Exit')
let $SAfter = 'Y'
break
when = 68 ! 0x44
let $SBefore = 'Y'
do WriteCode('Local')
let $SAfter = 'Y'
break
when = 69 ! 0x45
let $SBefore = 'Y'
do WriteCode('Global')
let $SAfter = 'Y'
break
when = 70 ! 0x46
let $SBefore = 'Y'
do WriteCode('**')
let $SAfter = 'Y'
break
when = 71 ! 0x47
let $SBefore = 'N'
do WriteCode('@')
let $SAfter = 'N'
break
when = 72 ! 0x48
! PeopleSoft object indicator (w/ object name)
let $SBefore = 'P'
do NextByte(#Byte1)
do NextByte(#Byte2) ! could be the high order byte of namenum
do Get-Object-Reference(#Byte1,$Recname, $Refname)
let $out = $RecName || '."' || $Refname || '"'
do WriteCode($out)
let $SAfter = 'P'
break
when = 73 ! 0x49
let $SBefore = 'Y'
do WriteCode('set')
let $SAfter = 'P'
break
when = 74 ! 0x4a
! PeopleSoft object indicator (w/o object name)
let $SBefore = 'P'
do NextByte(#Byte1)
do NextByte(#Byte2) ! could be the high order byte of namenum
do Get-Object-Reference(#Byte1,$Recname, $Refname)
do WriteCode($Refname)
let $SAfter = 'P'
break
when = 75 ! 0x4b
let $SBefore = 'Y'
do WriteCode('Null')
let $SAfter = 'Y'
break
when = 76 ! 0x4c
let $SBefore = 'Y'
do WriteCode('[')
let $SAfter = 'N'
break
when = 77 ! 0x4d
let $SBefore = 'N'
do WriteCode(']')
let $SAfter = 'Y'
break
when = 78 ! 0x4e
! Inline Code - Not really working since I have \n after certain commands
! Comment
let $SBefore = 'Y'
do NextByte(#lCommentLength1)
do NextByte(#lCommentLength2)
let #lCommentLength = (#lCommentLength2 * 256) + #lCommentLength1
let #i = 0
while #i < #lCommentLength
do NextByte(#tVal)
let $out = chr(#tVal)
do WriteCode($out)
do NextByte(#tVal)
add 2 to #i
end-while
let $SAfter = 'N'
do LineFeed
break
when = 79 ! 0x4f
! Blank Line
do LineFeed
break
when = 80 ! 0x50
! Number
let $SBefore = 'P'
do Get-Number($tVal)
do WriteCode($tVal)
let $SAfter = 'P'
break
when = 81 ! 0x51
let $SBefore = 'Y'
do WriteCode('PanelGroup')
let $SAfter = 'Y'
break
when = 83 ! 0x52
let $SBefore = 'Y'
do WriteCode('Doc')
let $SAfter = 'Y'
break
when = 84 ! 0x54
let $SBefore = 'Y'
do WriteCode('Component')
let $SAfter = 'Y'
break
when = 85 ! 0x55
! Block Comment <* *>
do NextByte(#lCommentLength1)
do NextByte(#lCommentLength2)
let #lCommentLength = (#lCommentLength2 * 256) + #lCommentLength1
let #i = 0
while #i < #lCommentLength
do NextByte(#tVal)
if #tVal = 10
do LineFeed
else
let $out = chr(#tVal)
do WriteCode($out)
end-if
do NextByte(#tVal)
add 2 to #i
end-while
do LineFeed
break
when = 86 ! 0x56
let $SBefore = 'Y'
do WriteCode('Constant')
let $SAfter = 'Y'
break
when = 87 ! 0x57
let $SBefore = 'N'
do WriteCode(':')
let $SAfter = 'N'
break
when = 88 ! 0x58
let $SBefore = 'Y'
do WriteCode('import')
let $SAfter = 'Y'
break
when = 89 ! 0x59
let $SBefore = 'N'
do WriteCode('*')
let $SAfter = 'N'
break
when = 90 ! 0x5a
let $SBefore = 'Y'
do WriteCode('class')
let $SAfter = 'Y'
break
when = 91 ! 0x5b
let $SBefore = 'Y'
do WriteCode('end-class')
let $SAfter = 'Y'
break
when = 92 ! 0x5c
let $SBefore = 'Y'
do WriteCode('extends')
let $SAfter = 'Y'
break
when = 93 ! 0x5d
let $SBefore = 'Y'
do WriteCode('out')
let $SAfter = 'P'
break
when = 94 ! 0x5e
let $SBefore = 'Y'
do WriteCode('property')
let $SAfter = 'Y'
break
when = 95 ! 0x5f
let $SBefore = 'Y'
do WriteCode('get')
let $After = 'P'
break
when = 96 ! 0x60
let $SBefore = 'Y'
do WriteCode('readonly')
let $After = 'P'
break
when = 97 ! 0x61
let $SBefore = 'Y'
do WriteCode('private')
do LineFeed
let $SAfter = 'Y'
break
when = 98 ! 0x62
let $SBefore = 'Y'
do WriteCode('instance')
let $SAfter = 'Y'
break
when = 99 ! 0x63
let $SBefore = 'Y'
do WriteCode('method')
let $SAfter = 'Y'
break
when = 100 ! 0x64
let $SBefore = 'Y'
do WriteCode('end-method')
let $SAfter = 'Y'
break
when = 101 ! 0x65
let $SBefore = 'Y'
do WriteCode('try')
do LineFeed
let $SAfter = 'Y'
break
when = 102 ! 0x66
let $SBefore = 'Y'
do WriteCode('catch')
let $SAfter = 'Y'
break
when = 103 ! 0x67
let $SBefore = 'Y'
do WriteCode('end-try')
let $SAfter = 'Y'
break
when = 104 ! 0x68
let $SBefore = 'Y'
do WriteCode('throw')
let $SAfter = 'Y'
break
when = 105 ! 0x69
let $SBefore = 'Y'
do WriteCode('create')
let $SAfter = 'Y'
break
when = 106 ! 0x6a
let $SBefore = 'Y'
do WriteCode('end-get')
let $SAfter = 'Y'
break
when = 107 ! 0x6b
let $SBefore = 'Y'
do WriteCode('end-set')
let $SAfter = 'Y'
break
when = 108 ! 0x6c
! Data Type
let $SBefore = 'Y'
do Get-String($tString)
do WriteCode($tString)
let $SAfter = 'Y'
break
when = 109 ! 0x6d
let $SBefore = 'Y'
do WriteCode('/+ ')
do Get-String($tString)
do WriteCode($tString)
do WriteCode(' +/')
let $SAfter = 'Y'
do LineFeed
break
when = 110 ! 0x6e
let $SBefore = 'Y'
do WriteCode('continue')
let $SAfter = 'Y'
break
when = 111 ! 0x6f
let $SBefore = 'Y'
do WriteCode('abstract')
let $SAfter = 'Y'
break
when = 112 ! 0x70
let $SBefore = 'Y'
do WriteCode('interface')
let $SAfter = 'Y'
break
when = 113 ! 0x71
let $SBefore = 'Y'
do WriteCode('end-interface')
let $SAfter = 'Y'
break
when = 114 ! 0x72
let $SBefore = 'Y'
do WriteCode('implements')
let $SAfter = 'Y'
break
when = 115 ! 0x73
let $SBefore = 'Y'
do WriteCode('protected')
let $SAfter = 'Y'
do LineFeed
break
when-other
show ''
show '**************'
show 'CodeLine: ' $Codeline
show 'Unknown:' #tVal
stop
break
end-evaluate
end-if
end-procedure
!*******************************************************************************
begin-procedure NextByte (:#tVal)
!*******************************************************************************
! Pulls off the first two characters from the $Code string that represent a
! hexadecimal value and converts them to a numeric value. If the $Code string
! is empty (e.g., when all of the two byte values have been processed), it will
! call the Get-Next-Segment function to return the next slice.
while isblank($_Code)
do Get-Next-Segment($_Code)
end-while
let $tVal1 = substr($_Code,1,1)
let $tVal2 = substr($_Code,2,1)
let $_Code = substr($_Code,3,length($_Code))
do HexToDec($tVal1)
do HexToDec($tVal2)
let #tVal = (16 * to_number($tVal1)) + to_number($tVal2)
end-procedure
!*******************************************************************************
begin-procedure Get-Next-Segment (:$inCode)
!*******************************************************************************
! First increment the Slice to get the next 2000 bytes from the current Segment.
! If there is no more data in the current Segment, check the next Segment,
! starting with the first Slice (= 0).
add 1 to #_Program_Slice
let $inCode = ''
let #offset = ({SLICE_SIZE} * #_Program_Slice) + 1
begin-select
PROGSEQ
Dbms_Lob.SubStr(PROGTXT,{SLICE_SIZE},#offset) &PROGTXT
let $inCode = &PROGTXT
FROM PSPCMPROG
WHERE [$_WhereClause]
AND PROGSEQ = #_Program_Segment
end-select
if isnull(&PROGSEQ)
show '**ERROR** No additional code found'
show ' Program Name: ' $_ProgName
show ' Program Seg : ' #_Program_Segment
show ' PROGSEQ : ' &PROGSEQ
stop
end-if
if isblank($inCode)
add 1 to #_Program_Segment
let #_Program_Slice = -1
end-if
end-procedure
!*******************************************************************************
begin-procedure HexToDec(:$in_char)
!*******************************************************************************
! Crude Hex to Decimal conversion
let $TestChar = lower($in_char)
evaluate $TestChar
when = 'a'
let $in_char = '10'
break
when = 'b'
let $in_char = '11'
break
when = 'c'
let $in_char = '12'
break
when = 'd'