#	CheckInActive - Check the active window in
#
#	Usage:	Called by a userdefined 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 readonly copy is left
#	in its place.
#
#	 Apple Computer, Inc. 1988
#	All rights reserved.

Set Exit 0
Set error 0
Begin

	#	First see if the active window belongs to a project.
	
	(Set info "`ProjectInfo "{Active}"`" || Set error 1)
	Evaluate "{info}" =~ /,[0-9a-z.]+([+*])1Owner/
	Evaluate "{info}" =~ /Project: (ź)2 +Checked out/
	If {error}  0 || "{info}" == ""
		Alert ""{Active}" cant be checked in because 
it doesnt belong to a project."
		Exit 0 
	End
	
	#	Find out if the active window is checked out for modification.

	If "'{1}'"  "'+'" &&  "'{1}'"  "'*'"
		Alert ""{Active}" cant be checked in because 
it wasnt checked out for modification."
		Exit 0 
	End
	
	#	Is the right project mounted?
	
	(Set info "`ProjectInfo "{2}"`" || Set error 1)
	If "{info}" == ""
		Alert ""{Active}" cant be checked in because the project 
"{2}" is not mounted."
		Exit 0 
	End

	#	Now request the comment and check the file in.
	set echo 1	
	(Set comment "`Request "What changes did you make?" || Set error {Status}`")
	If {error} == 0
		If "{comment}"  ""
			CheckIn -cs "{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
