	SUBROUTINE UPDATE(options, username, mail_data, fwd_length,
     +                    per_length, dir_length, privl, mail_node,
     +                    local_node, displayed_record)
C
	IMPLICIT INTEGER(A-Z)
	INTEGER*4 per_len, dir_len, for_len, name_len, option_len
	INTEGER*4 str$trim, colon_pos, user_len
	BYTE fwd_length, per_length, dir_length
	CHARACTER options(1)*256, mail_data*639, username*31
	CHARACTER personal*177, forward*256, directory*256, forward_node*31
	CHARACTER local_node*31, mail_node*31, name*256, forward_user*31
	EXTERNAL netmail_modfwd
C
	forward      = ' '
	forward_user = ' '
	forward_node = ' '
C
C	*****
C	Check for forward update.
C	*****
C
	icode = str$trim(options(4), options(4), option_len)
	If (option_len.ne.0) then
C
C	 Is the mail_node the same as the netmail node? Cannot set forward
C	 if it is because of infinite looping in VMSmail.
C
	 colon_pos = str$position(options(4), '::')
	 If(colon_pos.ne.0) then
	 colon_pos = colon_pos + 1
	 forward_node = options(4)(1:colon_pos)
	 forward_user = options(4)(colon_pos+1:option_len)
	 Else
	 forward_node = local_node
	 forward_user = options(4)(1:option_len)
	 Endif !Breakout of forward_node/forward_user.
C
	 If (forward_node.eq.mail_node) then
	 forward_node = ' '
	  If (forward_user.eq.username) then
	   forward_user = ' '
	   CALL LIB$SIGNAL(netmail_modfwd)
	  Endif !Match forward_user/username.
	 Endif !Match mail_node/forward_node.
C
	icode = str$trim(forward_node, forward_node, for_len)
	icode = str$trim(forward_user, forward_user, user_len)
	 If ((for_len.ne.0).and.(user_len.ne.0))
     +     forward = forward_node(1:for_len) // forward_user(1:user_len)
	 If ((for_len.eq.0).and.(user_len.ne.0))
     +     forward = forward_user(1:user_len)
	 If ((for_len.eq.0).and.(user_len.eq.0))
     +     forward = ' '
	icode = str$trim(forward, forward, for_len)
C
	Else
	 If(fwd_length.ne.0) then
	 forward = mail_data(1:fwd_length)
	 for_len = fwd_length
	 Else
	 forward = ' '
	 for_len = 0
	 Endif !Forward in mail_data check.
	Endif !Options(4) check.
C
C	*****
C	Check for personal update.
C	*****
C
	icode = str$trim(options(3), options(3), option_len)
	If (option_len.ne.0) then
	personal = options(3)(1:option_len)
	name_len=str$position(mail_data(1+fwd_length:fwd_length+31),'|')
	 If (name_len.ne.0)
     +   name = mail_data(1+fwd_length:fwd_length+name_len-1)
	per_len  = option_len
C
	Else
	If (per_length.ne.0) then
	personal = mail_data(1+fwd_length:fwd_length+per_length)
	icode = str$trim(personal, personal, per_len)
	Endif !Personal field check.
C
C	 Check to see if NAME field is present in PERSONAL field.
C
	 name_len=str$position(personal(1:31),'|')
	 If (name_len.ne.0) then
	 name = personal(1:name_len-1)
	 icode = str$trim(name, name, name_len)
	 personal = personal(name_len+2:per_len)
	 icode = str$trim(personal, personal, per_len)
	 Endif !Name update check.
	Endif !Personal update check.
C
C	*****
C	Check for name update.
C	*****
C
	icode = str$trim(options(2), options(2), option_len)
	If (option_len.ne.0) then
	name = options(2)(1:option_len)
	name_len  = option_len
C
	Else
	 icode = str$trim(name, name, name_len)
	 If (name_len.eq.0) name = ' '
	Endif !Name update check.
C
C	*****
C	Put PERSONAL and NAME fields together.
C	*****
C
	If (per_len.ne.0) then
	 If (name_len.ne.0) then
	  If (personal(1:1).eq.' ') then
	  personal = name(1:name_len) // '|' // personal(1:per_len)
	  Else
	  personal = name(1:name_len) // '| ' // personal(1:per_len)
	  Endif !NAME/PERSONAL space check.
	 Endif !NAME/PERSONAL mash.
	Else
	 If (name_len.ne.0) personal = name(1:name_len) // '| '
	 icode = str$trim(personal, personal, per_len)
	Endif !NAME mash into PERSONAL.
	icode = str$trim(personal, personal, per_len)
C
C	*****
C	Check username update.
C	*****
C
	icode = str$trim(options(1), options(1), option_len)
	If (option_len.ne.0) then
	username = options(1)(1:option_len)
	Endif !Name update check.
C
C	Build directory string, if there.
C
	If (dir_length.ne.0) then
	directory = mail_data(1+fwd_length+per_length:
     +                        fwd_length+per_length+dir_length)
	icode = str$trim(directory, directory, dir_len)
	Else
	directory = ' '
	Endif !Directory string check.
	icode = str$trim(directory, directory, dir_len)
C
C	*****
C	Build updated mail_data record
C	*****
C
	fwd_length = for_len
	per_length = per_len
	dir_length = dir_len

	mail_data = forward(1:for_len) // personal(1:per_len) //
     +              directory(1:dir_len)
C
	return
	end

