1	SUB SMG_ADD_VIRTUAL_DISPLAY(LONG Rows,LONG Columns,		&
		BYTE Video_attr, BYTE Border_flag)

	!---------------------------------------------------------------&
	!								&
	!		   SMG_ADD_VIRTUAL_DISPLAY			&
	!								&
	!		Creation Date:  3-July-1985			&
	!		Author:		Ken Messer			&
	! 		Purpose:        Create a new virtual display	&
	!								&
	!---------------------------------------------------------------&
	!								&
	! 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 LONG		RS,					&
				Video_attributes,			&
				Display_attributes

	EXTERNAL LONG FUNCTION	SMG$Create_virtual_display

	EXTERNAL LONG CONSTANT	SS$_Normal,				&
				SMG$M_Blink,				&
				SMG$M_Bold,				&
				SMG$M_Reverse,				&
				SMG$M_Underline,			&
				SMG$M_Border

	EXTERNAL STRING FUNCTION	Get_Error_Message(LONG)

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

	! Exit the routine if we're already maxed out on virtual displays

	GOTO Done	IF Number_virtual_displays = 10


	! Test the rendition mask and set the specified video attributes

	Display_attributes, Video_attributes = 0

	Video_attributes = Video_attributes OR SMG$M_Blink	 	&
		IF Video_attr AND 1

	Video_attributes = Video_attributes OR SMG$M_Bold		&
		IF Video_attr AND 2

	Video_attributes = Video_attributes OR SMG$M_Reverse		&
		IF Video_attr AND 4

	Video_attributes = Video_attributes OR SMG$M_Underline		&
		IF Video_attr AND 8


	! Set the border attribute if desired

	Display_attributes = Display_attributes OR SMG$M_Border		&
		IF Border_flag <> 0

	! Increment the virtual display counter

	Number_virtual_displays = Number_virtual_displays + 1
	Vir_disp_num = Number_virtual_displays - 1

	! Set up the definition file row and column variables for this display

	Display_rows(vir_disp_num) = Rows
	Display_cols(vir_disp_num) = Columns


	! Call the RTL routine to create the display

	RS = SMG$Create_virtual_display(Rows,Columns,			&
		Display_id(Vir_disp_num),Display_attributes,		&
		Video_attributes,)


	! Check for error

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

 Done:

32767	SUBEXIT

	END SUB
