1	SUB SMG_DELETE_LAST_VIRTUAL_DISPLAY

	!---------------------------------------------------------------&
	!								&
	!		   	   SMG_CLOSE				&
	!								&
	!		Creation Date:  19-Sep-1985			&
	!		Author:		Ken Messer			&
	! 		Purpose:        Delete the most recently	&
	!				created virtual display		&
	!								&
	!		Modification history				&
	!								&
	!	Date	Description of change(s)			&
	!								&
	!---------------------------------------------------------------&
	!								&
	! Copyright (c) 1985 -	Ken Messer, Allied Electronics, Inc.,	&
	!			401 E. 8th St., Ft. Worth, TX  76102	&
	!								&
	! This software may be copied and distributed freely to anyone	&
	! for non-commerical use provided that this copyright notice is &
	! included.							&
	!---------------------------------------------------------------&

	OPTION TYPE = INTEGER, SIZE = INTEGER LONG

	%include "SMG$LIBRARY:SMG.DFN"


	DECLARE BYTE CONSTANT		True = -1,			&
					False = 0

	DECLARE LONG			RS

	EXTERNAL LONG FUNCTION		SMG$Delete_virtual_display

	EXTERNAL STRING FUNCTION	Get_Error_Message(LONG)

	EXTERNAL LONG CONSTANT		SS$_Normal

	!---------------------------------------------------------------&
	!								&
	!		M a i n   P r o g r a m   L o g i c		&
	!								&
	!---------------------------------------------------------------&

	! Delete the most recently created virtual display and
	! decrement the count of virtual displays in the common area

	! NOTE:  This routine WILL NOT delete the default display (number 0)

	GOTO Done	IF Number_virtual_displays = 1

100	RS = SMG$Delete_virtual_display(Display_id(Number_virtual_displays - 1))

	IF RS AND SS$_Normal = 0   THEN
		PRINT Get_Error_Message(RS)
		STOP
	END IF

	Number_virtual_displays = Number_virtual_displays - 1

 Done:

32767	SUBEXIT

	END SUB
