*! version 1.0.0  02/02/93 extrname <extrname> utility; STB-13: dm13
program define _crcexn8 /* lname fname mname word cword */
	version 3.0
	local lname "`1'"
	local fname "`2'"
	local mname "`3'"
	local word  "`4'"
	local cword "`5'"

	tempvar bad

	quietly {
		local type : type `lname'
		local d=min(real(substr("`type'",4,.))+length("`cword'"),80)
		gen byte `bad' = trim(`mname')=="`word'"
		capture assert `bad'==0
		if _rc {
			minlen `d' `lname'
			replace `lname'="`cword'" + `lname' if `bad'
			replace `mname'="" if `bad'
		}
		replace `bad'=trim(`fname')=="`word'" & trim(`mname')==""
		capture assert `bad'==0
		if _rc {
			minlen `d' `lname'
			replace `lname'="`cword'" + `lname' if `bad'
			replace `fname'="" if `bad'
		}
		compress `lname' `fname' `mname'
	}
end