;UCS -          CONVERTS ENTIRE TEXT TO UPPER CASE; 
;		EXCLUDING WHAT MAY BE IN QUOTES!
;
;WRITTEN BY: 	JALAL RAISSI
;
;EDIT HISTORY:
;		1.0 01-JUN-85 CREATED. /JER
;		DAVE PALLMAN'S ENCODE WAS USED AS PROTOTYPE!
;FORMAT:
;		.UCS FILENAME
;		.UCS TEST.BAS
;
	VMAJOR=1
	VMINOR=1

	SEARCH	SYS
	SEARCH	SYSSYM

	.OFINI
	.OFDEF	IN,D.DDB		;INPUT FILE
	.OFDEF	OUT,D.DDB		;OUTPUT FILE
	.OFDEF	KEY,512.		;ENCRYPTION KEY
	.OFSIZ	MEMSIZ

	QT=D4

START:	PHDR	-1,0,PH$REE!PH$REU	;PROGRAM HEADER
	GETIMP	MEMSIZ,A5		;ALLOCATE IMPURE AREA

HELP:	BYP				;BYPASS LEADING WHITE SPACE
	LIN				;END OF LINE?
	JNE	GETIN			; NO	
	CRLF				;NEWLINE
	TYPECR	<FUNCTION: CONVERTS TEXT TO UPPER CASE.>
	TYPECR	<USAGE:    .UCS FILENAME>
	TYPECR	<EXAMPLE:  .UCS TEST.BAS>
	CRLF				;NEWLINE	
	EXIT				;EXIT		

GETIN:	MOV	A2,A3			;SAVE LINE INDEX
	FSPEC	IN(A5),BAS		;PROCESS FILESPEC
	INIT	IN(A5)			;LOAD DRIVER, ALLOCATE BUFFER

GETOUT:	MOV	A3,A2			;RESTORE LINE INDEX
	FSPEC	OUT(A5),BAS		;PROCESS FILESPEC
	INIT	OUT(A5)			;LOAD DRIVER, ALLOCATE BUFFER
	MOVW	#[$$$],OUT+D.EXT(A5)	;SET OUTPUT EXTENSION TO .$$$

OPNIN:	OPENI	IN(A5)			;OPEN INPUT FILE

OPNOUT:	LOOKUP	OUT(A5)			;CHECK FOR EXISTENCE OF OUTPUT FILE
	BNE	10$			;NOT FOUND
	DSKDEL	OUT(A5)			;DELETE OUTPUT FILE
10$:	OPENO	OUT(A5)			;OPEN OUTPUT FILE

GETBYT:	CTRLC	ENDFIL			;BRANCH ON ^C
	FILINB	IN(A5)			;READ BYTE
	TST	IN+D.SIZ(A5)		;TEST FOR END-OF-FILE
	BEQ	ENDFIL			;BRANCH ON END-OF-FILE
	CMPB	D1,#42			;IS IT A "
	BNE	SKPQT
	TSTB	QT
	BEQ	SET
	CLR	QT
	BR	SKPQT
SET:
	MOVB	#1,QT
SKPQT:
	CMPB	D1,#12			;IS IT A LF
	BNE	SKPLF
	CLR	QT
SKPLF:
	TSTB	QT
	BNE	TTY
	UCS	D1			;CONVERT CHARACTER TO UCS
TTY:	TTY

PUTBYT:	FILOTB	OUT(A5)			;OUTPUT UCSED BYTE
	BR	GETBYT			;LOOP TILL END OF FILE

ENDFIL:	CLOSE	IN(A5)
	CLOSE	OUT(A5)
	CTRLC	ABORT

DELIN:	DSKDEL	IN(A5)

RENOUT:	MOV	IN+D.FIL(A5),OUT+D.DDB(A5)
	MOVW	IN+D.EXT(A5),OUT+D.DDB+4(A5)
	DSKREN	OUT(A5)
	EXIT

ABORT:	DSKDEL	OUT(A5)
	EXIT

	END