changing the computer/rendevous name

Does anyone know how to change the computer’s shared name and the rendevous name? Preferably without going through system preferences. I have a script I can use to change it that way, but when it quits sys. prefs. the name reverts to it’s old form. I know that the computer name is stored as APPLETALK_HOSTNAME in /etc/hostconfig but I have no idea where the rendezvous name is stored.

Here is the UI Scripting style app that I wrote.

set reply to display dialog "Enter the computer number and I'll do the rest" default answer "" buttons {"521", "508D", "Cancel"} default button 3

set x to the button returned of reply
set y to the text returned of reply

set comp to x & "-" & y
set rend to "cs-" & x & "-" & y

tell application "System Preferences" to activate
tell application "System Events"
	tell process "System Preferences"
		click menu item "Sharing" of menu "View" of menu bar 1
		delay 4
		set value of text field 1 of window "Sharing" to comp
		set value of text field 2 of window "Sharing" to rend
		delay 1
		click radio button "Services" of tab group 1 of window "Sharing"
		--		click button 1 of window "Sharing"
		-- click button "Show All" of tool bar 1 of window "Sharing"
	end tell
end tell
tell application "System Preferences" to quit

The names of 508D and 521 are room numbers which make up the first part of the name convention. This code works pretty well, except for the not actually finishing the change name part. the last few lines after “delay 1” were odd attempts to make it save after quitting system prefs.