.ENABLE SUBSTITUTION
.ENABLE QUIET
.DISABLE DISPLAY
.ENABLE CONTROL-Z
.ENABLE ESCAPE
.;
.; RPTBLD.CMD --
.;
.SETS ext ".RPT"				! Default extension.
.SETS til ""
.SETS since ""
.SETF delt					! Don't delete by default.
.SETS date ""
.SETS time ""
.SETS filnam ""
.SETS file "F"					! Default to file output.
.SETS device "ALL"
.SETS numb " "					! Default to all units in one
.SETS rpttyp ""
.SETS infile ""					! If you want a default input
.;						! file other than the
.;						! destination file for
.;						! the MERGE command, put it
.;						! here.
.;
.SETF insrpt
.IFINS ...RPT .OR .IFF <privil> .GOTO Chknly
.DISABLE QUIET
;%RPTBLD-I-INS, Installing RPT.
.ENABLE QUIET
.IFNINS ...RPT .IFT <privil> .SETT insrpt
.IFNINS ...RPT .IFT <privil> INS $RPT
.Chknly:
.IFNINS ...RPT .GOTO Errrpt
.S1:
.ASKS since What is the starting date for the report [DD-MMM-YY]: 
.IFT <eof> .GOTO Xit
.IFF <escape> .GOTO Cont1
	.DISABLE QUIET
	;
	; The correct format for the date is DD-MMM-YY, eg.:
	;
	;     07-MAY-86
	;     12-AUG-59
	;
	; Please try again.
	;
	.ENABLE QUIET
	.GOTO S1
.Cont1:
.IF since = "" .SETS since "*"
.;
.S2:
.ASKS til What is the ending date for the report [DD-MMM-YY]: 
.IFT <eof> .GOTO Xit
.IFF <escape> .GOTO Cont2
	.DISABLE QUIET
	;
	; The correct format for the date is DD-MMM-YY, eg.:
	;
	;     07-MAY-86
	;     12-AUG-59
	;
	; Please try again.
	;
	.ENABLE QUIET
	.GOTO S2
.Cont2:
.IF til = "" .SETS til "*"
.;
.; Check which data file(s) to use.
.;
.DISABLE QUIET
;%RPTBLD-I-FIL, Building log file list....
.ENABLE QUIET
.;
.; CHKFIL will compile matching error log files into a temporary file
.; TMPERR.LOG.
.;
.SETS curdat til
.IF til = "*" .SETS curdat <DATE>
.PARSE curdat "-" day curmon curyr
.TEST day
.IF <strlen> <= 1 .SETS curdat "0'curdat'"
.SETS stdat since
.IF stdat = "*" .SETS stdat <date>
.PARSE stdat "-" day stmon styr
.TEST day
.IF <strlen> <= 1 .SETS stdat "0'stdat'"
@CHKFIL 'stmon' 'styr' 'curmon' 'curyr'
.IF <exstat> <> 1 .GOTO Errfil
.IF curdat = <date> PIP TMPLOG.ERR/AP=LB:[1,6]LOG.ERR
.SETS newfil "SY:'<uic>'TMPLOG.ERR"
.;
.S211:
.ASKS rpttyp Enter the report type [B/F/R]: 
.IFT <eof> .GOTO Xit
.IFF <escape> .GOTO Cnt211
	.DISABLE QUIET
	;
	; The three report types are:
	;
	;     B is BRIEF, the default,
	;     F is FULL, and
	;     R is REGISTER.
	;
	.ENABLE QUIET
	.GOTO S211
.Cnt211:
.IF rpttyp = "" .SETS rpttyp "BRIEF"
.IF rpttyp = "F" .OR .IF rpttyp = "f" .SETS rpttyp "FULL"
.IF rpttyp = "R" .OR .IF rpttyp = "r" .SETS rpttyp "REGISTER"
.IF rpttyp = "B" .OR .IF rpttyp = "b" .SETS rpttyp "BRIEF"
.IF rpttyp <> "FULL" .IF rpttyp <> "REGISTER" .IF rpttyp <> "BRIEF" .GOTO S211
.;
.S21:
.DISABLE QUIET
;Enter the device mnemonic for this report.  If all devices are desired,
.ENABLE QUIET
.ASKS device use RETURN: 
.IFT <eof> .GOTO Xit
.IFF <escape> .GOTO Cont21
	.DISABLE QUIET
	;
	; The device mnemonic is the two letter device name, such as:
	;
	;     DU, MS, and DM
	;
	; The default is for ALL devices.
	;
	.ENABLE QUIET
	.GOTO S21
.Cont21:
.IF device = "" .SETS device "ALL"
.S22:
.IF device = "ALL" .GOTO S3
	.ASKS numb Enter the device number, if desired: 
	.IFT <eof> .GOTO Xit
	.IFF <escape> .GOTO Cont22
		.DISABLE QUIET
		;
		; The device number is a one or two digit number, where
		; if the device is DU1:, the number is 1, and for
		; DU10:, the number is 10.  The default is for all devices
		; with your input mnemonic.
		;
		.ENABLE QUIET
		.GOTO S22
.Cont22:
.IF numb = "" .OR .IF numb = " " .GOTO S3
	.SETS device device+numb
	.PARSE device ":" device rest
	.SETS device device+":"
.;
.S3:
.ASKS file Output to: T - Terminal or F - File [T/F]: 
.IFT <eof> .GOTO Xit
.IFF <escape> .GOTO Cont3
	.DISABLE QUIET
	;
	; Output can be directed to either your terminal for immediate
	; reading or saved in a file with a name of the form:
	;
	;     MMMDDYY.RPT where:
	;
	;          MMM is the month mnemonic, eg. AUG, DEC,
	;          DD is the day, and
	;          YY is the year.
	;
	; This file will be saved in your current default UIC.
	;
	.ENABLE QUIET
	.GOTO S3
.Cont3:
.IF file = "" .SETS file "F"
.IF file <> "T" .IF file <> "t" .IF file <> "F" .IF file <> "f" .GOTO S3
.IF file = "t" .OR .IF file = "T" .SETS filnam "TI:"
.IF filnam = "TI:" .GOTO Start
.SETS date <date>
.SETS filnam date[4:6]+date[1:2]+date[10:11]+ext
.;
.Start:
.DISABLE QUIET
;%RPTBLD-I-START, Starting report generation;  this may take a while,
;                 depending upon how many days you have requested.
.ENABLE QUIET
.;
ELI /-LO					! Turn off error logging.
.XQT RPT 'filnam'='newfil'/DA:R:'since':'til'/DE:'device'/F:'rpttyp'
.TESTFILE TI:
.PARSE <filspc> ":" term rest
.SETS term term[2:*]
.Loop2:
	.DELAY 15S
	.IFNACT RPT'term' .GOTO Xitlp2
		.DISABLE QUIET
		;%RPTBLD-I-ACT, Working....
		.ENABLE QUIET
		.GOTO Loop2
.Xitlp2:
.IF <exstat> <> 1 .GOTO Errrun
.DISABLE QUIET
;%RPTBLD-I-SUC, RPT completed.
.ENABLE QUIET
.Cont8:
.DISABLE QUIET
;%RPTBLD-I-CLN, Cleaning up work files.
.ENABLE QUIET
PIP 'newfil';*/DE/NM
.Rstrt:
ELI /LO						! Start logging again.
.IFF insrpt .GOTO Xit
.DISABLE QUIET
;%RPTBLD-I-REM, Removing RPT.
.ENABLE QUIET
.IFT insrpt REM ...RPT
.Xit:
.EXIT
.;
.; Error processing.
.;
.Err:
	.DISABLE QUIET
	;%RPTBLD-F-FIL, Input file could not be created.
	.ENABLE QUIET
	.GOTO Xit
.Errrpt:
	.DISABLE QUIET
	;%RPTBLD-F-RPT, RPT could not be installed, exiting...
	.ENABLE QUIET
	.GOTO Xit
.Errrun:
	.DISABLE QUIET
	;%RPTBLD-F-RPT, RPT failed.
	.ENABLE QUIET
	.GOTO .Cont8
.Errfil:
	.DISABLE QUIET
	;%RPTBLD-F-FIL, File open or access failure.
	.ENABLE QUIET
	.GOTO Xit
