1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER process-options
AS CHAR NO-UNDO.
9 DEF VAR preview
AS LOGICAL NO-UNDO INITIAL No.
10 DEF VAR archive
AS CHAR NO-UNDO INITIAL "Yes".
11 DEF VAR log-depth
AS INT NO-UNDO INITIAL 10.
13 IF RETURN-VALUE = 'FAIL'
THEN RETURN.
15 DEF VAR program-list
AS CHAR NO-UNDO INITIAL "".
16 DEF VAR no-programs
AS INT NO-UNDO INITIAL 0.
17 DEF VAR found-list
AS CHAR NO-UNDO INITIAL "".
18 DEF VAR include-list
AS CHAR NO-UNDO INITIAL "".
19 DEF VAR checked-incs
AS CHAR NO-UNDO INITIAL "".
21 DEF VAR k
AS INT NO-UNDO.
23 DEF VAR log-name
AS CHAR NO-UNDO INITIAL '
{&FILE-NAME}.log'.
25 OS-DELETE ss-fix.bat .
27 /* _UIB-CODE-BLOCK-END
*/
31 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
33 /* ******************** Preprocessor Definitions
******************** */
35 &Scoped-define PROCEDURE-TYPE Procedure
39 /* _UIB-PREPROCESSOR-BLOCK-END
*/
44 /* *********************** Procedure Settings
************************ */
46 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
47 /* Settings for
THIS-PROCEDURE
51 Add Fields to
: Neither
52 Other Settings
: CODE-ONLY
COMPILE
54 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
56 /* ************************* Create Window
************************** */
58 &ANALYZE-SUSPEND _CREATE-WINDOW
59 /* DESIGN Window definition
(used by the UIB
)
60 CREATE WINDOW Procedure
ASSIGN
63 /* END WINDOW DEFINITION
*/
69 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
70 /* ************************* Included-Libraries
*********************** */
72 {inc
/method
/m-txtrep.i
}
74 /* _UIB-CODE-BLOCK-END
*/
79 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
82 /* *************************** Main Block
*************************** */
83 RUN log
( 1, "*********************************************************************").
84 RUN log
( 1, "Looking for Crapola!").
86 /* Check for programs that aren't referenced
*/
87 RUN process-dir
( ".", "*", ".P,.W" ).
91 RUN check-programlinks.
95 /* check for .R code where there is no source
*/
96 RUN check-orphan-rcode.
100 /* Check for include files that weren't referenced
*/
101 IF RETURN-VALUE <> 'FAIL'
THEN DO:
104 RUN process-dir
( ".\inc", "*", ".I").
106 RUN archive-programs.
109 /* while we're at it...
*/
110 IF RETURN-VALUE <> 'FAIL'
THEN RUN check-menus.
112 IF RETURN-VALUE = 'FAIL'
THEN
113 RUN log
( 1, 'Crapola search aborted'
).
115 RUN log
( 1, 'Crapola search complete'
).
118 txtrep-print-file
= log-name.
119 RUN view-output-file
( preview
).
122 /* _UIB-CODE-BLOCK-END
*/
126 /* ********************** Internal Procedures
*********************** */
128 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE archive-programs Procedure
129 PROCEDURE archive-programs
:
130 /*------------------------------------------------------------------------------
132 ------------------------------------------------------------------------------*/
133 DEF VAR file-name
AS CHAR NO-UNDO.
134 DEF VAR i
AS INT NO-UNDO.
135 DEF VAR do-it
AS LOGICAL NO-UNDO.
137 IF archive
= 'Yes'
THEN
138 RUN log
( 3, "Moving remaining " + STRING( no-programs
) + " files to archive." ).
139 ELSE IF archive
= 'Prompt'
THEN
140 RUN log
( 3, "Prompt for remaining " + STRING( no-programs
) + " files to archive." ).
141 ELSE IF archive
= 'Prompt'
THEN
142 RUN log
( 3, "Not moving remaining " + STRING( no-programs
) + " files to archive." ).
143 RUN log
( 22, program-list
).
145 OS-CREATE-DIR ..\archive .
146 OS-CREATE-DIR ..\archive\vwr .
/* directory has sub-dirs
, but no content
*/
147 DO i
= 1 TO no-programs
:
148 file-name
= ENTRY( i
, program-list
).
151 IF archive
= 'Prompt'
THEN DO:
152 MESSAGE "Move '" + file-name
+ "' to archive?" VIEW-AS ALERT-BOX QUESTION
153 BUTTONS YES-NO-CANCEL
154 TITLE "Archive this program?"
156 IF do-it
= ?
THEN RETURN 'FAIL'.
158 ELSE if archive
<> 'Yes'
THEN
162 RUN log
( 4, STRING( i
, '
>>9'
) + '
: '
+ file-name
).
163 file-name
= SUBSTRING( file-name
, 3).
164 OS-CREATE-DIR VALUE( "..\archive\"
165 + SUBSTRING( file-name
, 1, R-INDEX( file-name
, "\") - 1)).
166 OS-DELETE VALUE( "..\archive\" + file-name
).
167 OS-RENAME VALUE(file-name
) VALUE( "..\archive\" + file-name
).
169 IF SUBSTRING( file-name
, LENGTH(file-name
) - 1) <> ".R" THEN DO:
170 OUTPUT TO ss-fix.bat
APPEND.
171 PUT UNFORMATTED "x-x-x-x\SS Delete $/"
172 + REPLACE( file-name
, "\", "/")
173 + " -S -I-Y -YAndrew" SKIP.
178 RUN log
( 4, STRING( i
, '
>>9'
) + '
: '
+ file-name
+ " - not moved to archive." ).
184 /* _UIB-CODE-BLOCK-END
*/
188 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-file Procedure
189 PROCEDURE check-file
:
190 /*------------------------------------------------------------------------------
191 Purpose
: Check an individual file
192 ------------------------------------------------------------------------------*/
193 DEF INPUT PARAMETER file-name
AS CHAR NO-UNDO.
195 DEF VAR ln
AS CHAR NO-UNDO.
196 DEF VAR i
AS INT NO-UNDO.
197 DEF VAR l-no
AS INT NO-UNDO INITIAL 0.
198 DEF VAR save-include-list
AS CHAR NO-UNDO.
200 i
= R-INDEX( file-name
, ".R").
201 IF i
> 0 THEN file-name
= SUBSTRING( file-name
, 1, i
- 1).
203 IF SEARCH( file-name
) <> ?
THEN .
204 ELSE IF SEARCH( file-name
+ ".W" ) <> ?
THEN file-name
= file-name
+ ".W".
205 ELSE IF SEARCH( file-name
+ ".P" ) <> ?
THEN file-name
= file-name
+ ".P".
206 ELSE IF SEARCH( file-name
+ ".I" ) <> ?
THEN file-name
= file-name
+ ".I".
208 save-include-list
= include-list.
210 RUN log
( 15, "Checking '" + file-name
+ "' for recursive calls.").
211 INPUT FROM VALUE( file-name
).
213 IMPORT UNFORMATTED ln.
215 i
= INDEX( ln
, "~{i" + "nc" ) .
/* hide search string so we don't generate errors parsing ourselves
! */
216 IF i
> 0 THEN RUN check-ln-inc
( ln
, i
).
217 i
= INDEX( ln
, "RUN").
219 RUN check-ln-run
( file-name
, INPUT-OUTPUT l-no
, ln
, i
).
224 IF include-list
<> "" THEN RUN check-inside-includes.
225 include-list
= save-include-list.
229 /* _UIB-CODE-BLOCK-END
*/
233 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-includes Procedure
234 PROCEDURE check-includes
:
235 /*------------------------------------------------------------------------------
237 ------------------------------------------------------------------------------*/
238 DEF VAR i
AS INT NO-UNDO.
239 DEF VAR no-incs
AS INT NO-UNDO.
241 RUN log
( 3, "Processing " + STRING( no-programs
) + " include files.").
242 RUN log
( 5, "Marking previously checked includes as found.").
243 no-incs
= NUM-ENTRIES( checked-incs
) - 1.
245 RUN program-found
( ENTRY( i
, checked-incs
) ).
250 /* _UIB-CODE-BLOCK-END
*/
254 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-inside-includes Procedure
255 PROCEDURE check-inside-includes
:
256 /*------------------------------------------------------------------------------
257 Purpose
: Read each include we've found and look for
RUN ... or
{ inc ...
}
258 ------------------------------------------------------------------------------*/
259 DEF VAR i
AS INT NO-UNDO.
261 DEF VAR inc-name
AS CHAR NO-UNDO.
263 RUN log
( 33, "Checking includes found so far for further calls.").
264 DO i
= 1 TO NUM-ENTRIES( include-list
) - 1:
265 inc-name
= ENTRY( i
, include-list
).
266 IF LOOKUP( inc-name
, checked-incs
) > 0 THEN NEXT.
268 checked-incs
= checked-incs
+ inc-name
+ ",".
269 RUN check-file
( ENTRY( i
, include-list
) ).
271 RUN log
( 33, "Checking of includes completed.").
275 /* _UIB-CODE-BLOCK-END
*/
279 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-linknodes Procedure
280 PROCEDURE check-linknodes
:
281 /*------------------------------------------------------------------------------
283 ------------------------------------------------------------------------------*/
284 DEF VAR i
AS INT NO-UNDO.
285 DEF VAR base-file
AS CHAR NO-UNDO.
286 DEF VAR prog-file
AS CHAR NO-UNDO.
287 DEF VAR pb
AS INT NO-UNDO.
289 RUN log
( 3, "Removing known linknode targets from list of " + STRING(no-programs
) + " programs.").
292 IF LinkNode.NodeType
= "MV" THEN DO:
293 IF NOT CAN-FIND( FIRST ProgramLink
WHERE ProgramLink.Viewer
= LinkNode.File
) THEN
294 RUN log
( 7, "MV Linknode '" + LinkNode.Description
295 + "' - no ProgramLink found for viewer '" + LinkNode.File
+ "'").
298 /* LinkNode.Path
= REPLACE( LinkNode.Path
, "\", "/").
*/
299 /* IF LinkNode.Path
= "win/sel" OR LinkNode.Path
= "win/mnt" THEN LinkNode.Path
= "win".
*/
300 /* IF LinkNode.Path
= "win/lnk" OR LinkNode.Path
= "vwr/lnk" THEN LinkNode.Path
= "lnk".
*/
302 base-file
= REPLACE( LinkNode.Path
+ '\'
303 + (IF LinkNode.RunFile
<> "" THEN
306 LinkNode.File
), '
/'
, '\'
).
308 IF LOOKUP( base-file
, found-list
) > 0 THEN NEXT.
309 IF INDEX( found-list
, base-file
) > 0 THEN NEXT.
310 /* IF INDEX( found-list
, (IF LinkNode.RunFile
<> "" THEN LinkNode.RunFile
ELSE LinkNode.File
)) > 0 THEN NEXT.
*/
312 IF SUBSTRING( base-file
, 1, 2) <> ".\" THEN prog-file
= ".\" + base-file.
313 i
= LOOKUP( prog-file
+ ".W", program-list
).
315 i
= LOOKUP( prog-file
+ ".P", program-list
).
317 i
= LOOKUP( prog-file
, program-list
).
319 prog-file
= prog-file
+ ".P".
322 prog-file
= prog-file
+ ".W".
325 RUN log
( 9, "Linknode '" + LinkNode.Description
+ "' - '"
326 + LinkNode.Path
+ " - " + LinkNode.RunFile
+ "' not found.").
327 i
= INDEX( program-list
, (IF LinkNode.RunFile
= "" THEN LinkNode.File
ELSE LinkNode.RunFile
) ).
329 pb
= R-INDEX( program-list
, ",", i
) + 1.
330 LinkNode.Path
= REPLACE( SUBSTRING( program-list
, pb
+ 2, i
- pb
- 3), "\", "/").
331 RUN log
( 1, "Linknode changed to: '"
332 + LinkNode.Path
+ "' for the path. ("
333 + STRING(pb
) + "," + STRING(i
) + ")" ).
337 RUN program-found
( prog-file
).
340 RUN log
( 99, "Program list: " + program-list
).
344 /* _UIB-CODE-BLOCK-END
*/
348 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-ln-inc Procedure
349 PROCEDURE check-ln-inc
:
350 /*------------------------------------------------------------------------------
352 ------------------------------------------------------------------------------*/
353 DEF INPUT PARAMETER ln
AS CHAR NO-UNDO.
354 DEF INPUT PARAMETER i
AS INT NO-UNDO.
356 ln
= REPLACE( ENTRY( 1, SUBSTRING( ln
, i
+ 1), " "), "/", "\").
357 ln
= TRIM( ln
, "~{} ").
358 IF SUBSTRING( ln
, 1, 2) <> ".\" THEN ln
= ".\" + ln.
359 IF LOOKUP( ln
, checked-incs
) > 0 THEN RETURN.
361 RUN log
( 47, "Found include: '" + ln
+ "'").
362 include-list
= include-list
+ ln
+ ",".
366 /* _UIB-CODE-BLOCK-END
*/
370 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-ln-run Procedure
371 PROCEDURE check-ln-run
:
372 /*------------------------------------------------------------------------------
374 ------------------------------------------------------------------------------*/
375 DEF INPUT PARAMETER file-name
AS CHAR NO-UNDO.
376 DEF INPUT-OUTPUT PARAMETER l-no
AS INT NO-UNDO.
377 DEF INPUT PARAMETER whole-ln
AS CHAR NO-UNDO.
378 DEF INPUT PARAMETER i
AS INT NO-UNDO.
380 DEF VAR ln
AS CHAR NO-UNDO.
382 ln
= TRIM( SUBSTRING( whole-ln
, i
+ 4) ).
383 ln
= RIGHT-TRIM( ln
, ".").
384 IF SUBSTRING( ln
, 1, 11) = "init-object" THEN DO:
385 ln
= REPLACE( ln
, '
"', "'
").
386 IF INDEX( ln, "'
") > 0 THEN
387 ln = TRIM( ENTRY( 2, ln, "'
") ).
389 /* Probably UIB code to init windows - next line should have program name */
391 IMPORT UNFORMATTED ln.
392 ln = REPLACE( ln, '"'
, "'").
393 IF INDEX( ln
, "'") = 0 THEN RETURN "".
/* it gets too hard...
*/
394 ln
= ENTRY( 2, ln
, "'").
396 RUN log
( 21, file-name
+ ' '
+ STRING(l-no
) + ": Parsed 'init-object' line to get '" + ln
+ "'").
398 IF SUBSTRING( ln
, 1, 5) = "VALUE" THEN RETURN "".
/* can't cope
! */
399 IF SUBSTRING( ln
, 1, 3) = "ade" THEN RETURN "".
/* not our problem
*/
400 IF SUBSTRING( ln
, 1, 3) = "adm" THEN RETURN "".
/* not our problem
*/
401 IF SUBSTRING( ln
, 1, 7) = "prodict" THEN RETURN "".
/* not our problem
*/
403 i
= INDEX( ln
, "(" ).
404 IF i
> 0 THEN ln
= SUBSTRING( ln
, 1, i
- 1).
/* trim to start of parameter list
*/
405 ln
= REPLACE( ENTRY( 1, ln
, " "), "/", "\").
/* trim to first space
*/
406 IF INDEX( ln
, "\") = 0 THEN RETURN "".
/* all R-U-Ns should use explicit path
*/
408 i
= R-INDEX( ln
, ".R").
409 IF i
> 0 THEN ln
= SUBSTRING( ln
, 1, i
- 1).
411 DEF VAR prog-file
AS CHAR NO-UNDO.
412 DEF VAR pb
AS INT NO-UNDO.
414 IF SUBSTRING( prog-file
, 1, 2) <> ".\" THEN prog-file
= ".\" + prog-file.
415 i
= LOOKUP( prog-file
, program-list
).
417 i
= LOOKUP( prog-file
+ ".W", program-list
).
418 IF i
> 0 THEN prog-file
= prog-file
+ ".W".
420 i
= LOOKUP( prog-file
+ ".P", program-list
).
421 IF i
> 0 THEN prog-file
= prog-file
+ ".P".
426 RUN log
( 31, "RUN '" + ln
+ "' encountered").
427 RUN program-found
( prog-file
).
431 IF INDEX( found-list
, ln
) > 0 THEN RETURN "".
433 RUN log
( 9, "Problem parsing line " + STRING(l-no
) + " of " + file-name
).
434 RUN log
( 9, " -->" + whole-ln
+ "<--").
435 RUN log
( 9, "Run program '" + ln
+ "' not found. (prog-file=" + prog-file
+ ")").
440 /* _UIB-CODE-BLOCK-END
*/
444 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-menus Procedure
445 PROCEDURE check-menus
:
446 /*------------------------------------------------------------------------------
448 ------------------------------------------------------------------------------*/
449 DEF BUFFER OtherLink
FOR LinkNode.
451 FOR EACH LinkNode
NO-LOCK:
452 FIND FIRST UsrGroupMenu
WHERE UsrGroupMenu.NodeCode
= LinkNode.NodeCode
NO-LOCK NO-ERROR.
453 IF NOT AVAILABLE(UsrGroupMenu
) THEN DO:
454 IF CAN-FIND( FIRST ProgramLink
WHERE ProgramLink.Source
= LinkNode.NodeCode
AND ProgramLink.LinkType
<> "SEL" ) THEN
455 RUN log
( 7, "No menu for Linknode '" + LinkNode.Description
+ "'.").
458 IF LinkNode.NodeType
= "MV" THEN DO:
459 FIND FIRST ProgramLink
NO-LOCK WHERE ProgramLink.Source
= LinkNode.NodeCode
460 AND ProgramLink.LinkType
= 'SEL'
NO-ERROR.
461 IF AVAILABLE(ProgramLink
) THEN NEXT.
462 RUN log
( 7, "LinkNode is Maintain Viewer without selection links '" + LinkNode.Description
+ "'.").
465 FIND FIRST ProgramLink
NO-LOCK WHERE ProgramLink.Source
= LinkNode.NodeCode
NO-ERROR.
466 IF AVAILABLE(ProgramLink
) THEN NEXT.
468 FIND FIRST ProgramLink
NO-LOCK WHERE ProgramLink.Target
= LinkNode.NodeCode
NO-ERROR.
469 IF AVAILABLE(ProgramLink
) THEN NEXT.
471 RUN log
( 6, "No reference to Linknode '" + LinkNode.Description
+ "'.").
474 FOR EACH ProgramLink
NO-LOCK:
475 FIND FIRST LinkNode
WHERE LinkNode.NodeCode
= ProgramLink.Source
NO-LOCK NO-ERROR.
476 IF NOT AVAILABLE(LinkNode
) THEN
477 RUN log
( 6, "Invalid source for ProgramLink '" + ProgramLink.Description
+ "'.").
479 FIND FIRST LinkNode
WHERE LinkNode.NodeCode
= ProgramLink.Target
NO-LOCK NO-ERROR.
480 IF NOT AVAILABLE(LinkNode
) THEN
481 RUN log
( 6, "Invalid target for ProgramLink '" + ProgramLink.Description
+ "'.").
483 IF ProgramLink.LinkType
= "SEL" THEN NEXT.
485 IF CAN-FIND( FIRST UsrGroupMenuItem
WHERE UsrGroupMenuItem.LinkCode
= ProgramLink.LinkCode
) THEN DO:
486 FOR EACH UsrGroupMenuItem
NO-LOCK WHERE UsrGroupMenuItem.LinkCode
= ProgramLink.LinkCode
487 AND NOT CAN-FIND( UsrGroup
OF UsrGroupMenuItem
):
488 RUN log
( 8, "Group '" + UsrGroupMenuItem.GroupName
+ "' not defined for programlink '" + ProgramLink.Description
+ "'.").
492 RUN log
( 10, "No menu item links ProgramLink '" + ProgramLink.Description
+ "'.").
497 /* _UIB-CODE-BLOCK-END
*/
501 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-orphan-rcode Procedure
502 PROCEDURE check-orphan-rcode
:
503 /*------------------------------------------------------------------------------
505 ------------------------------------------------------------------------------*/
506 DEF VAR i
AS INT NO-UNDO.
507 DEF VAR source-list
AS CHAR NO-UNDO.
508 DEF VAR no-sources
AS INT NO-UNDO.
509 DEF VAR prog-name
AS CHAR NO-UNDO.
511 RUN log
( 3, "Searching for orphan r-code.").
514 RUN process-dir
( ".", "*", ".P,.W" ).
515 source-list
= program-list.
516 no-sources
= no-programs.
520 RUN process-dir
( ".", "*", ".R").
522 DO i
= 1 TO no-sources
:
523 prog-name
= ENTRY( i
, source-list
).
524 prog-name
= SUBSTRING( prog-name
, 1, LENGTH(prog-name
) - 1 ) + "R".
525 RUN program-found
( prog-name
).
527 RUN log
( 9, "Found " + STRING( no-programs
) + " orphans.").
531 /* _UIB-CODE-BLOCK-END
*/
535 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-programlinks Procedure
536 PROCEDURE check-programlinks
:
537 /*------------------------------------------------------------------------------
539 ------------------------------------------------------------------------------*/
540 DEF VAR i
AS INT NO-UNDO.
541 DEF VAR prog-file
AS CHAR NO-UNDO.
542 DEF VAR pb
AS INT NO-UNDO.
544 RUN log
( 3, "Removing known program link viewers from list of " + STRING(no-programs
) + " programs.").
546 FOR EACH ProgramLink
:
547 IF NOT ProgramLink.CreateViewer
THEN NEXT.
548 IF ProgramLink.Viewer
= 'Default'
THEN ProgramLink.Viewer
= ''.
549 IF ProgramLink.Viewer
= ''
THEN NEXT.
550 prog-file
= ProgramLink.Viewer.
551 i
= INDEX( program-list
, prog-file
).
553 pb
= R-INDEX( program-list
, ",", i
) + 1.
554 /* ProgramLink.FillName
= REPLACE( SUBSTRING( program-list
, pb
+ 2, i
- pb
- 3), "\", "/").
*/
556 i
= INDEX( program-list
, ",", pb
).
558 prog-file
= SUBSTRING( program-list
, pb
, i
- pb
).
560 prog-file
= SUBSTRING( program-list
, pb
).
563 i
= LOOKUP( prog-file
, program-list
).
564 IF i
> 0 THEN RUN program-found
( prog-file
).
568 RUN log
( 99, "Program list: " + program-list
).
572 /* _UIB-CODE-BLOCK-END
*/
576 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-programs Procedure
577 PROCEDURE check-programs
:
578 /*------------------------------------------------------------------------------
579 Purpose
: Read each program we've found and look for
RUN ... or
{ inc...
}
580 ------------------------------------------------------------------------------*/
581 DEF VAR i
AS INT NO-UNDO.
583 RUN log
( 3, "Removing calls from inside found programs from list of " + STRING(no-programs
) + " programs.").
585 DO i
= 1 TO NUM-ENTRIES( found-list
) - 1:
586 RUN check-file
( ENTRY( i
, found-list
) ).
588 RUN log
( 99, "Program list: " + program-list
).
592 /* _UIB-CODE-BLOCK-END
*/
596 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-triggers Procedure
597 PROCEDURE check-triggers
:
598 /*------------------------------------------------------------------------------
600 ------------------------------------------------------------------------------*/
601 DEF VAR i
AS INT NO-UNDO.
602 DEF VAR trig-file
AS CHAR NO-UNDO.
603 DEF VAR pb
AS INT NO-UNDO.
605 RUN log
( 3, "Removing known triggers from list of " + STRING(no-programs
) + " programs.").
606 REPEAT i
= 1 TO NUM-ALIASES:
607 RUN log
( 23, "Alias " + STRING(i
, "99 ") + ALIAS(i
) + " = " + LDBNAME(ALIAS(i
)) + " ==> " + PDBNAME(ALIAS(i
))) .
610 FOR EACH dictdb._File-Trig
NO-LOCK:
611 trig-file
= REPLACE( dictdb._File-Trig._Proc-Name
, '
/'
, '\'
).
612 IF SUBSTRING( trig-file
, 1, 8) <> "TRIGGER\" THEN trig-file
= "TRIGGER\" + trig-file.
613 trig-file
= ".\" + trig-file.
615 i
= LOOKUP( trig-file
, program-list
).
617 RUN program-found
( trig-file
).
619 RUN log
(5, "Trigger '" + trig-file
+ "' not found.").
622 FOR EACH dictdb._Field-Trig
NO-LOCK:
623 trig-file
= REPLACE( dictdb._Field-Trig._Proc-Name
, '
/'
, '\'
).
624 IF SUBSTRING( trig-file
, 1, 8) <> "TRIGGER\" THEN trig-file
= "TRIGGER\" + trig-file.
625 trig-file
= ".\" + trig-file.
627 i
= LOOKUP( trig-file
, program-list
).
629 RUN program-found
( trig-file
).
631 RUN log
(5, "Trigger '" + trig-file
+ "' not found.").
634 RUN log
( 99, "Program list: " + program-list
).
638 /* _UIB-CODE-BLOCK-END
*/
642 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE known-problems Procedure
643 PROCEDURE known-problems
:
644 /*------------------------------------------------------------------------------
645 Purpose
: Mark known problems as 'found'
646 ------------------------------------------------------------------------------*/
647 DEF VAR p1
AS INT NO-UNDO.
648 DEF VAR p2
AS INT NO-UNDO.
650 RUN log
( 3, "Marking known problems as 'found'").
652 RUN log
( 12, "Marking all in .\process\one-off as found. No-programs = " + STRING(no-programs
)).
653 p1
= INDEX( program-list
, ".\process\one-off\" ).
655 p2
= R-INDEX( program-list
, ".\process\one-off\" ).
656 p2
= INDEX( program-list
, ",", p2
).
657 RUN log
( 24, "p1 = " + STRING(p1
) + ", p2 = " + STRING(p2
)
658 + ", substring( list, p1, 30) = " + SUBSTRING( program-list
, p1
, 30)
659 + ", substring( list, p2-10, 30) = " + SUBSTRING( program-list
, p2
- 10, 30)).
662 found-list
= found-list
+ SUBSTRING( program-list
, p1
, p2
- p1
+ 1).
664 found-list
= found-list
+ SUBSTRING( program-list
, p1
) + ",".
666 program-list
= SUBSTRING( program-list
, 1, p1
- 1 )
667 + (IF p2
> 0 THEN SUBSTRING( program-list
, p2
+ 1) ELSE "").
669 no-programs
= NUM-ENTRIES( program-list
).
670 RUN log
( 12, "Done marking .\process\one-off as found. No-programs = " + STRING(no-programs
)).
672 /*****************************************************************************
673 Inside this comment go the subsidiary calls
, which means that they will be
674 found when we process findcrap.p
(which is in the process\one-off
675 directory and so will be found
). They're not meant to compile
(!) so
676 the trailing period is missing from each line.
677 ******************************************************************************
680 RUN process\loadusrs.p
681 RUN process\dumpall.p
682 RUN process\dumpmost.p
683 RUN process\report\report.p
684 RUN process\report\schdakld.p
685 RUN process\report\schdsdny.p
686 RUN process\report\schdglen.p
687 RUN process\report\cntrtlst.p
688 RUN process\report\lglnam.p
689 RUN process\report\tntaddr.p
690 RUN process\report\wofexpry.p
691 RUN process\report\menulist.p
692 RUN process\report\vcntspce.p
693 RUN process\report\rntlarea.p
694 ******************************************************** That's all folks...
*/
696 RUN log
( 3, "Finished marking known problems.").
700 /* _UIB-CODE-BLOCK-END
*/
704 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE log Procedure
706 /*------------------------------------------------------------------------------
707 Purpose
: write output formatted as a log entry
708 ------------------------------------------------------------------------------*/
709 DEF INPUT PARAMETER depth
AS INT NO-UNDO.
710 DEF INPUT PARAMETER entry-text
AS CHAR NO-UNDO.
712 IF depth
> log-depth
THEN RETURN.
713 OUTPUT TO VALUE(log-name
) KEEP-MESSAGES APPEND.
714 PUT UNFORMATTED STRING( YEAR(TODAY), "9999") + "-" + STRING( MONTH(TODAY), "99") + "-" + STRING( DAY(TODAY), "99")
715 + " " + STRING( TIME, "HH:MM:SS")
716 + " " + STRING( depth
, ">>9")
722 /* _UIB-CODE-BLOCK-END
*/
726 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-options Procedure
727 PROCEDURE parse-options
:
728 /*------------------------------------------------------------------------------
730 ------------------------------------------------------------------------------*/
731 DEF VAR i
AS INT NO-UNDO.
732 DEF VAR token
AS CHAR NO-UNDO.
734 DO i
= 1 TO NUM-ENTRIES( process-options
, "~n" ):
735 token
= ENTRY( i
, process-options
, "~n" ).
736 CASE ENTRY( 1, token
):
737 WHEN "Log-Depth" THEN log-depth
= INTEGER( TRIM(ENTRY( 2, token
))).
738 WHEN "Preview" THEN preview
= (ENTRY( 2, token
) = "Yes").
739 WHEN "Archive" THEN archive
= ENTRY( 2, token
).
741 MESSAGE "Unknown option '" + token
+ "' ignored."
742 VIEW-AS ALERT-BOX WARNING
743 TITLE "Unknown option".
752 /* _UIB-CODE-BLOCK-END
*/
756 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE process-dir Procedure
757 PROCEDURE process-dir
:
758 /*------------------------------------------------------------------------------
759 Purpose
: Add programs in a directory onto program-list
760 ------------------------------------------------------------------------------*/
761 DEF INPUT PARAMETER path
AS CHAR NO-UNDO.
762 DEF INPUT PARAMETER spec
AS CHAR NO-UNDO.
763 DEF INPUT PARAMETER extensions
AS CHAR NO-UNDO.
765 DEF VAR file-name
AS CHAR NO-UNDO.
766 DEF VAR full-path
AS CHAR NO-UNDO.
767 DEF VAR file-type
AS CHAR NO-UNDO.
768 DEF VAR extension
AS CHAR NO-UNDO.
770 DEF VAR dir-list
AS CHAR INITIAL "" NO-UNDO.
771 DEF VAR no-dirs
AS INT INITIAL 0 NO-UNDO.
772 DEF VAR i
AS INT NO-UNDO.
774 INPUT FROM OS-DIR( path
) .
775 directory-entry-loop
:
778 IMPORT file-name full-path file-type.
779 file-type
= SUBSTRING( file-type
, 1, 1).
781 /* skip .
, ..
, ... etc.
*/
782 IF SUBSTRING( file-name
, 1, 1) = "." THEN NEXT directory-entry-loop.
786 dir-list
= dir-list
+ (IF dir-list
= "" THEN "" ELSE ",") + path
+ "\" + file-name.
790 ASSIGN extension
= SUBSTRING( file-name
, R-INDEX( file-name
, '.'
) ) NO-ERROR.
791 IF file-name
MATCHES spec
AND LOOKUP( extension
, extensions
) > 0 THEN DO:
792 full-path
= path
+ '\'
+ file-name.
793 IF LOOKUP( full-path
, program-list
) = 0 THEN ASSIGN
794 program-list
= program-list
795 + (IF no-programs
= 0 THEN "" ELSE ",")
797 no-programs
= no-programs
+ 1.
806 no-dirs
= NUM-ENTRIES( dir-list
).
808 full-path
= ENTRY( i
, dir-list
).
809 RUN log
( 35, "Recursing into '" + full-path
+ "'").
810 RUN process-dir
( full-path
, spec
, extensions
).
815 /* _UIB-CODE-BLOCK-END
*/
819 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE program-found Procedure
820 PROCEDURE program-found
:
821 /*------------------------------------------------------------------------------
825 ------------------------------------------------------------------------------*/
826 DEF INPUT PARAMETER prog-file
AS CHAR NO-UNDO.
828 DEF VAR i
AS INT NO-UNDO.
830 RUN log
(29, "Program '" + prog-file
+ "' found - " + STRING(no-programs
) + " remain.").
832 i
= INDEX( program-list
, prog-file
).
834 program-list
= SUBSTRING( program-list
, 1, i
- 1)
835 + SUBSTRING( program-list
, i
+ LENGTH(prog-file
) + 1)
836 found-list
= found-list
+ prog-file
+ ","
837 no-programs
= no-programs
- 1.
839 RUN log
( 5, "Program '" + prog-file
+ "' found, but not located in program-list!").
843 /* _UIB-CODE-BLOCK-END
*/