#	CheckInActive - Check the active window in
#
#	Usage:	Called by a user–defined menu item
#
#	CheckInActive uses the Request command to allow the user to 
#	type in a short comment to catalog the changes that were
#	made to the file since it was last checked out. Once the
#	comment is entered, the file open as the Active window is
#	checked in to its parent project and a read–only copy is left
#	in its place.
#
#	© Apple Computer, Inc. 1988
#	All rights reserved.

Set Exit 0
Set error 0
Begin

	#	First see if the User is defined.
	
	If "{User}" == ""
		Alert 'The {User} variable is not defined.'
	End
	
	#	Next see if the active window belongs to a project.
	
	(Set info "`ProjectInfo "{Active}"`" || Set error 1)
	Evaluate "{info}" =~ /[¬,]+[¬ ∂t+*]+([+*]«0,1»)®1≈/
	Evaluate "{info}" =~ /≈Project: (≈∫)®2 +Checked out≈/
	If {error} ≠ 0 || "{info}" == ""
		Alert "∂"{Active}∂" can’t be checked in because ∂
it doesn’t belong to a project."
		Exit 0 
	End
	
	#	Find out if the active window is checked out for modification.

	If "'{®1}'" ≠ "'+'" && "'{®1}'" ≠ "'*'"
		Alert "∂"{Active}∂" can’t be checked in because ∂
it wasn’t checked out for modification."
		Exit 0 
	End
	
	#	Is the right project mounted?
	
	(Set tmp "`ProjectInfo -only "{®2}"`" || Set error 1)
	If "{tmp}" == ""
		Alert "∂"{Active}∂" can’t be checked in because the project ∂
∂"{®2}∂" is not mounted."
		Exit 0 
	End
	
	#	Now request the comment and check the file in.
	
	Evaluate "{info}" =~ /≈Task: (≈)®1/

	(Set comment "`Request -d "{®1}" "What changes did you make?" || Set error {Status}`")
	If {error} == 0
		If "{comment}" ≠ ""
			CheckIn -t "{comment}" "{Active}"
		Else
			CheckIn "{Active}"
		End
		If {Status} ≠ 0
			Alert "There was a problem checking in ∂"{Active}∂". ∂
You need to check it in on a branch."
		End
	End
End ∑ dev:null
