	SUBROUTINE SETUP_PARITY (PARITY)
C
C	Get and set the parity for the remote.
C
C	Inputs:
C		PARITY = The parity type to setup.
C
	INCLUDE 'COM.INC/NOLIST'
	INCLUDE '($TTDEF)/NOLIST'

	INTEGER*4 STATUS
	CHARACTER*(*) PARITYQ, PARITY_DEFAULT, PARITY

	PARAMETER (PARITYQ = 'Enter the parity for the remote port (')
	PARAMETER (PARITY_DEFAULT = 'NONE')
C
C	Check for the parity type first incase we're in the startup code.
C
	IF (LEN(PARITY) .GT. 0) THEN		! If GT, set parity type.
	    PARITY_TYPE = PARITY		! Copy specified parity,
	    PARITY_SIZE = LEN(PARITY)		!    and the parity size.
	    GO TO 230				! Go parse the parity type.
	ENDIF
C
C	If in the startup code, look for the parity type symbol.
C
	IF (STARTUP) THEN
	    STATUS = GET_SYMBOL ('PARITY_TYPE', PARITY_TYPE, PARITY_SIZE)
	ENDIF
C
C	If no parity type is defined yet, setup the default parity.
C
	IF (PARITY_SIZE .EQ. 0) THEN
	    PARITY_TYPE = PARITY_DEFAULT	! Default parity type
	    PARITY_SIZE = LEN(PARITY_DEFAULT)	!   and the parity size.
	ENDIF
C
C	If the parity is defined at startup then parse it, otherwise return.
C
	IF (STARTUP) THEN			! We're in the startup code.
	    IF (STATUS) THEN
		GO TO 230			! Go parse the parity type.
	    ELSE
		RETURN				! Return to the startup code.
	    ENDIF
	ENDIF
C
C	Prompt the user for the parity type.
C
200	CALL PROMPT_USER (PARITYQ//PARITY_TYPE(1:PARITY_SIZE)//'): '
	1			,%REF(SCRATCH), LEN(PARITY_TYPE))
	IF (BACKUP) RETURN			! Backup to previous question.
	IF (WANTS_HELP) THEN
225	    CALL GET_HELP ('SET PARITY')	! Give the user some help.
	    GOTO 200				! Reprompt for parity type.
	ENDIF
C
C	See if the parity type is acceptable.
C
	IF (LBYTE_COUNT .GT. 0) THEN		! If GT, get user input.
	    PARITY_TYPE = SCRATCH(1:LBYTE_COUNT)! Copy the parity type.
	    PARITY_SIZE = LBYTE_COUNT		! Setup the parity size.
	ENDIF
C
C	Parse the parity type.
C
230	IF     (PARITY_TYPE(1:PARITY_SIZE) .EQ. 'EVEN') THEN
		REMOTE_PARITY = TT$M_ALTRPAR + TT$M_PARITY
	ELSEIF (PARITY_TYPE(1:PARITY_SIZE) .EQ. 'NONE') THEN
		REMOTE_PARITY = TT$M_ALTRPAR
	ELSEIF (PARITY_TYPE(1:PARITY_SIZE) .EQ. 'ODD') THEN
		REMOTE_PARITY = TT$M_ALTRPAR + TT$M_PARITY + TT$M_ODD
	ELSE
		CALL WRITE_USER ('*** Invalid PARITY type "'//
	1			PARITY_TYPE(1:PARITY_SIZE)//'" ***'//SS)
		IF (UNIX_MODE) THEN
			GO TO 200		! Request system type again.
		ELSE
			GO TO 225		! Invalid, give some help.
		ENDIF
	ENDIF
	CALL SETUP_REMOTE (.TRUE.)		! Setup the parity type.
	RETURN
	END
