1	SUB SMG_ADD_PASTEBOARD(STRING Output_device)

	!---------------------------------------------------------------&
	!								&
	!		      SMG_ADD_PASTEBOARD			&
	!								&
	!		Creation Date:  3-July-1985			&
	!		Author:		Ken Messer			&
	! 		Purpose:        Create a new pasteboard	and a	&
	!				virtual keyboard to go along	&
	!				with it				&
	!								&
	!		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 LONG			RS

	EXTERNAL LONG CONSTANT		SS$_Normal,			&
					SMG$_Pasalrexi,			&
					LIB$_Insvirmem

	EXTERNAL LONG FUNCTION		SMG$Create_pasteboard,		&
					SMG$Create_virtual_keyboard,	&
					SMG$Set_keypad_mode

	EXTERNAL STRING FUNCTION	Get_Error_Message(LONG)

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

	! Create the pasteboard - if all goes well, create a virtual
	! keyboard for it as well

100	RS = SMG$Create_pasteboard(Pasteboard_id(Number_pasteboards),	&
		Output_device,,,)

	SELECT RS
	   CASE SS$_Normal
		Number_pasteboards = Number_pasteboards + 1
		GOTO Create_virtual_keyboard
	   CASE	SMG$_Pasalrexi
		PRINT "You have already assigned a pasteboard to this device"
		STOP
	   CASE	LIB$_Insvirmem
		PRINT "Insufficient virtual memory to create another pasteboard"
		STOP
	   CASE ELSE
		PRINT "Unable to use this device (device not available?)"
		STOP
	END SELECT

	GOTO Done

 Create_virtual_keyboard:

	! Create a virtual keyboard for the same device

200	RS = SMG$Create_virtual_keyboard(Keyboard_id(Number_pasteboards - 1), &
		Output_device,,)

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

	! Place the keypad in numeric mode

300	RS = SMG$Set_keypad_mode(Keyboard_id(Number_pasteboards - 1),0)

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

 Done:

32767	SUBEXIT

	END SUB
