	INTEGER*2	POINT,POINTX,LENG,LENGX,LENGTH
	CHARACTER	CMDLIN*132,BUFF*132,PROTECT*69
	BYTE		LINE(132)
	EQUIVALENCE	(LINE,CMDLIN)
	DATA	PROTECT	/'SET PROTECTION=(S:RWED,O:RWED,G:RWED,W:RWED) 
	9	SCR$PASSWORD'/


	ISTAT = LIB$GET_FOREIGN (CMDLIN,'Please enter option:  ',LENG)

	IF (LENG .EQ. 0) GOTO 499

	IF ((LINE(1) .EQ. 'H') .OR. (LINE(1) .EQ. 'h') .OR.
	9	 (LINE(1) .EQ. '?')) GOTO 500
	IF ((LINE(1) .EQ. 'L') .OR. (LINE(1) .EQ. 'l')) THEN
	 GOTO 100
	ELSEIF ((LINE(1) .EQ. 'A') .OR. (LINE(1) .EQ. 'a')) THEN
	 GOTO 200
	ELSEIF ((LINE(1) .EQ. 'M') .OR. (LINE(1) .EQ. 'm')) THEN
	 GOTO 300
	ELSEIF ((LINE(1) .EQ. 'D') .OR. (LINE(1) .EQ. 'd')) THEN
	 GOTO 400
	ELSE
499	 CONTINUE
	 TYPE 1000
500	 CONTINUE
	 TYPE 3000
	 TYPE 3001
	 TYPE 3002
	 TYPE 3003
	 TYPE 3004
	 CALL SYS$EXIT (%VAL(1))
	ENDIF

100	CONTINUE

	OPEN (UNIT=1,ERR=999,NAME='SCR$PASSWORD',TYPE='OLD')

	DO WHILE (1)

	READ (1,2000,END=210)LENGTH,BUFF

	IF (LENGTH .NE. 0) TYPE 1001,BUFF(1:LENGTH)

	READ (1,2000,END=210)LENGTH,BUFF

	ENDDO

200	CONTINUE

	POINT = 1 

	DO 201, J=1,LENG
	 IF ((LINE(J) .EQ. ' ') .OR. (LINE(J) .EQ. '	')) GOTO 202
	 POINT = POINT+1
	 LENG = LENG-1
201	CONTINUE
	GOTO 998

202	CONTINUE

	IF (LENG .EQ. 0) GOTO 998

	DO 203, J=POINT,LENG+POINT
	 IF ((LINE(J) .NE. ' ') .AND. (LINE(J) .NE. '	')) GOTO 204
	 POINT = POINT+1
	 LENG = LENG-1
203	CONTINUE
	GOTO 998

204	CONTINUE

	LENGX = 0
	POINTX = POINT

	DO 205, J=POINT,LENG+POINT
	 IF ((LINE(J) .EQ. ' ') .OR. (LINE(J) .EQ. '	')) GOTO 206
	 POINT = POINT+1
	 LENG = LENG-1
	 LENGX = LENGX+1
205	CONTINUE
	GOTO 998

206	CONTINUE

	DO 207, J=POINT,LENG+POINT
	 IF ((LINE(J) .NE. ' ') .AND. (LINE(J) .NE. '	')) GOTO 208
	 POINT = POINT+1
	 LENG = LENG-1
207	CONTINUE
	GOTO 998

208	CONTINUE

	LENGTH=0

	DO 209, J=POINT,LENG+POINT
	  LENGTH=LENGTH+1
	  LINE(J)=LINE(J)+LENGTH+LENGTH
209	CONTINUE

	OPEN (UNIT=1,ERR=999,NAME='SCR$PASSWORD',TYPE='UNKNOWN',
	9 CARRIAGECONTROL='LIST',ACCESS='APPEND')

	WRITE (1,1002) (CMDLIN(POINTX:(POINTX+LENGX-1)))

	WRITE (1,1002) (CMDLIN(POINT:(POINT+LENG-1)))

210	CONTINUE

	CLOSE (UNIT=1)

	CALL SYS$EXIT (%VAL(1))

300	CONTINUE

	POINT = 1 

	DO 301, J=1,LENG
	 IF ((LINE(J) .EQ. ' ') .OR. (LINE(J) .EQ. '	')) GOTO 302
	 POINT = POINT+1
	 LENG = LENG-1
301	CONTINUE
	GOTO 998

302	CONTINUE

	IF (LENG .EQ. 0) GOTO 998

	DO 303, J=POINT,LENG+POINT
	 IF ((LINE(J) .NE. ' ') .AND. (LINE(J) .NE. '	')) GOTO 304
	 POINT = POINT+1
	 LENG = LENG-1
303	CONTINUE
	GOTO 998

304	CONTINUE

	LENGX = 0
	POINTX = POINT

	DO 305, J=POINT,LENG+POINT
	 IF ((LINE(J) .EQ. ' ') .OR. (LINE(J) .EQ. '	')) GOTO 306
	 POINT = POINT+1
	 LENG = LENG-1
	 LENGX = LENGX+1
305	CONTINUE
	GOTO 998

306	CONTINUE

	DO 307, J=POINT,LENG+POINT
	 IF ((LINE(J) .NE. ' ') .AND. (LINE(J) .NE. '	')) GOTO 308
	 POINT = POINT+1
	 LENG = LENG-1
307	CONTINUE
	GOTO 998

308	CONTINUE

	LENGTH=0

	DO 309, J=POINT,LENG+POINT
	  LENGTH=LENGTH+1
	  LINE(J)=LINE(J)+LENGTH+LENGTH
309	CONTINUE

	OPEN (UNIT=1,ERR=999,NAME='SCR$PASSWORD',TYPE='OLD',
	9 DISPOSE='DELETE')
	OPEN (UNIT=2,ERR=999,NAME='SCR$PASSWORD',TYPE='NEW',
	9 CARRIAGECONTROL='LIST')

	DO WHILE (1)

	READ (1,2000,END=410)LENGTH,BUFF

	IF (INDEX(CMDLIN(POINTX:(POINTX+LENGX)),BUFF(1:LENGTH)) .EQ. 1) THEN
	  WRITE (2,1002) BUFF(1:LENGTH)
	  READ (1,2000,END=410)LENGTH,BUFF
	  WRITE (2,1002) (CMDLIN(POINT:(POINT+LENG-1)))
	ELSE
	  WRITE (2,1002) BUFF(1:LENGTH)
	  READ (1,2000,END=410)LENGTH,BUFF
	  WRITE (2,1002) BUFF(1:LENGTH)
	ENDIF	

	ENDDO

400	CONTINUE

	OPEN (UNIT=1,ERR=999,NAME='SCR$PASSWORD',TYPE='OLD',
	9 DISPOSE='DELETE')
	OPEN (UNIT=2,ERR=999,NAME='SCR$PASSWORD',TYPE='NEW',
	9 CARRIAGECONTROL='LIST')

	POINT = 1 

	DO 401, J=1,LENG
	 IF ((LINE(J) .EQ. ' ') .OR. (LINE(J) .EQ. '	')) GOTO 402
	 POINT = POINT+1
	 LENG = LENG-1
401	CONTINUE
	GOTO 998

402	CONTINUE

	IF (LENG .EQ. 0) GOTO 998

	DO 403, J=POINT,LENG+POINT
	 IF ((LINE(J) .NE. ' ') .AND. (LINE(J) .NE. '	')) GOTO 404
	 POINT = POINT+1
	 LENG = LENG-1
403	CONTINUE
	GOTO 998

404	CONTINUE

	LENG = LENG-1

	DO WHILE (1)

	READ (1,2000,END=410)LENGTH,BUFF

	IF (INDEX(CMDLIN(POINT:(POINT+LENG)),BUFF(1:LENGTH)) .EQ. 1) THEN
	  READ (1,2000,END=410)LENGTH,BUFF
	ELSE
	  WRITE (2,1002) BUFF(1:LENGTH)
	  READ (1,2000,END=410)LENGTH,BUFF
	  WRITE (2,1002) BUFF(1:LENGTH)
	ENDIF	

	ENDDO

410	CONTINUE

	CLOSE (UNIT=2)
	CLOSE (UNIT=1)

	ISTAT = LIB$SPAWN (PROTECT)
	
	CALL SYS$EXIT (%VAL(1))

997	CONTINUE
998	CONTINUE
999	CONTINUE
	TYPE 1000

	CLOSE (UNIT=1)

	CALL SYS$EXIT (%VAL(4))

1000	FORMAT(X,'PASSWORD -- COMMAND LINE ERROR')
1001	FORMAT(X,A)
1002	FORMAT(A)
2000	FORMAT(Q,A)
3000	FORMAT(X,/,X,'The following are legal inputs to the Password
	9 Utility:')
3001	FORMAT(X,/,'		LIST<cr>')
3002	FORMAT(X,/,'		ADD name password<cr>')
3003	FORMAT(X,/,'		MODIFY name password<cr>')
3004	FORMAT(X,/,'		DELETE name<cr>',/,/,/)

	END
