COMPILE FUNCTION Note_Message(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)

/*
	Commuter module for Note_Message dialog window
	
	03/1/2010 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, Center_Window, Post_Event, RList
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow, Notes_Services
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, Create_Note, obj_Notes_Sent

DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Popup, Collect.Ixvals, Admin_User, Printer_Select, obj_Notes
DECLARE FUNCTION Send_Message, Msg, Security_Check, obj_React_Run_CI, MemberOf, Get_Printer, obj_Install,Set_Printer
DECLARE FUNCTION NextKey, Ex_VM_Rem

$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU
$INSERT POPUP_EQUATES
$INSERT LOGICAL
$INSERT OIPRINT_EQUATES
$INSERT RLIST_EQUATES

EQU COL$CL_NO			TO 1

EQU COL$ST_ID			TO 1
EQU COL$ST_NAME			TO 2


ErrTitle = 'Error in Note_Message routine'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLOSE'			; GOSUB Close
			CASE Event = 'READ'				; GOSUB Read
			CASE Event = 'WRITE'			; GOSUB Write
		END CASE
	
	CASE EntID = @WINDOW:'.YOUR_GROUPS' AND Event = 'CLICK'			; GOSUB YourGroupsClick
	CASE EntID = @WINDOW:'.ALL_ACTIVE_USERS' AND Event = 'CLICK'	; GOSUB	AllActiveUsersClick
	CASE EntID = @WINDOW:'.ALL_USERS' AND Event = 'CLICK'			; GOSUB	AllUsersClick
	CASE EntID = @WINDOW:'.COPY_YOURSELF' AND Event = 'CLICK'		; GOSUB CopyYourSelfClick
	CASE EntID = @WINDOW:'.REPLY' AND Event = 'CLICK'				; GOSUB Reply
	CASE EntID = @WINDOW:'.REPLY_ALL' AND Event = 'CLICK'			; GOSUB Reply
	CASE EntID = @WINDOW:'.FORWARD' AND Event = 'CLICK'				; GOSUB Forward
	CASE EntID = @WINDOW:'.ATTACHMENT_BUTTON' AND Event = 'CLICK'	; GOSUB ViewAttachment
	CASE EntID = @WINDOW:'.SEND_TO' AND Event = 'POSCHANGED'		; GOSUB SendToPC
	CASE EntID = @WINDOW:'.PRINT' AND Event = 'CLICK'				; GOSUB Print
	
	CASE 1
		ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
		ErrMsg(ErrorMsg)
		
END CASE

IF ErrorMsg NE '' THEN
	ErrMsg(ErrTitle:@SVM:ErrorMsg)
END

RETURN Result


* * * * * * *
Create:
* * * * * * *

	obj_Appwindow('Create',@WINDOW)

	IF Parm1 NE '' THEN
		AttachWindow	= Parm1[1,@FM]
		AttachKey		= Parm1[COL2()+1,@FM]
		
		IF AttachWindow NE '' THEN
			Set_Property(@WINDOW,'@ATTACH_WINDOW',AttachWindow)
			Set_Property(@WINDOW,'@ATTACH_KEY',AttachKey)
		END
	END

	GOSUB Refresh

RETURN


* * * * * * *
Close:
* * * * * * *

	End_Dialog(@WINDOW,'')

RETURN


* * * * * * *
Refresh:
* * * * * * *

	IF MemberOf(@USER4,'OI_ADMIN') THEN
		Set_Property(@WINDOW:'.SEQ','VISIBLE',1)
	END ELSE
		Set_Property(@WINDOW:'.SEQ','VISIBLE',0)
	END

	IF Get_Property(@WINDOW:'.ENTRY_ID','DEFPROP') = '' THEN
		Set_Property(@WINDOW:'.ENTRY_ID','ENABLED',1)
	END ELSE
		Set_Property(@WINDOW:'.ENTRY_ID','ENABLED',0)
	END

	IF Get_Property(@WINDOW:'.ENTRY_DATE','DEFPROP') = '' THEN
		Set_Property(@WINDOW:'.ENTRY_DATE','ENABLED',1)
	END ELSE
		Set_Property(@WINDOW:'.ENTRY_DATE','ENABLED',0)
	END

	IF Get_Property(@WINDOW:'.ENTRY_TIME','DEFPROP') = '' THEN
		Set_Property(@WINDOW:'.ENTRY_TIME','ENABLED',1)
	END ELSE
		Set_Property(@WINDOW:'.ENTRY_TIME','ENABLED',0)
	END

	AttachWindow = Get_Property(@WINDOW:'.ATTACH_WINDOW','DEFPROP')
	IF AttachWindow NE '' THEN
		Set_Property(@WINDOW:'.ATTACH_GROUP','ENABLED',1)
	END ELSE
		Set_Property(@WINDOW:'.ATTACH_GROUP','ENABLED',0)
	END

	* Turn edit table symbolic column backgrounds to green

	ETSymbolics = Get_Property(@WINDOW,'@ET_SYMBOLICS')		;* Loaded during 'Create' in obj_Appwindow

	ETCtrls	= ETSymbolics<1>
	ETCols	= ETSymbolics<2>

	FOR I = 1 TO COUNT(ETCtrls,@VM) + (ETCtrls NE '')
		ETCtrl	= ETCtrls<1,I>
		
		ETList = Get_Property(ETCtrl,'LIST')
		FOR Line = 1 TO COUNT(ETList,@FM) + (ETList NE '')
			IF ETList<Line,1> NE '' THEN
				FOR N = 1 TO COUNT(ETCols<1,I>,@SVM) + (ETCols<1,I> NE '')
					stat = Send_Message(ETCtrl,'COLOR_BY_POS',ETCols<1,I,N>,Line,GREEN$)
				NEXT N
			END
		NEXT Line
		
	NEXT I


	RETURN


* * * * * * *
Read:
* * * * * * *

	EntryID	= Get_Property(@WINDOW:'.ENTRY_ID','DEFPROP')

	IF EntryID = '' THEN
		Set_Property(@WINDOW:'.ENTRY_ID','DEFPROP',@USER4)
		Send_Event(@WINDOW:'.ENTRY_ID','LOSTFOCUS')
		Set_Property(@WINDOW:'.ENTRY_DATE','DEFPROP',OCONV(Date(),'D4/'))
		Set_Property(@WINDOW:'.ENTRY_TIME','DEFPROP',OCONV(Time(),'MTS'))
		
		AttachWindow = Get_Property(@WINDOW,'@ATTACH_WINDOW')
		AttachKey = Get_Property(@WINDOW,'@ATTACH_KEY')
		
		IF AttachWindow NE '' THEN Set_Property(@WINDOW:'.ATTACH_WINDOW','DEFPROP',AttachWindow)
		IF AttachKey NE '' THEN Set_Property(@WINDOW:'.ATTACH_KEY','DEFPROP',AttachKey)
		
		Set_Property(@WINDOW:'.FROM','DEFPROP',@USER4)
		Send_Event(@WINDOW:'.FROM','LOSTFOCUS')
		Send_Event(@WINDOW:'.ENTRY_ID','LOSTFOCUS')
		
		Set_Property('SYSTEM','FOCUS',@WINDOW:'.SUBJECT')
		
		Set_Property(@WINDOW:'.REPLY','ENABLED',0)
		Set_Property(@WINDOW:'.REPLY_ALL','ENABLED',0)
		Set_Property(@WINDOW:'.FORWARD','ENABLED',0)
		Set_Property(@WINDOW:'.MENU.FILE.SAVE_ROW','ENABLED',1)
		
	END ELSE
		Set_Property(@WINDOW:'.SEND','ENABLED',0)
	END

	GOSUB Refresh

RETURN


* * * * * * *
Write:
* * * * * * *

	NoteID = Get_Property(@WINDOW:'.SEQ','DEFPROP')

	SendToArray = Get_Property(@WINDOW:'.SEND_TO','ARRAY')
	SendToIDs	= SendToArray<COL$ST_ID>

	IF RowExists('NOTES',NoteID) THEN

		Send_Event(@WINDOW,'CLEAR',0,1,1)
		Send_Event(@WINDOW,'CLOSE')
		
	END ELSE

		Forward_Event()		
		Notes_Services('AddToQueue', NoteId)

	END

RETURN 0


* * * * * * *
YourGroupsClick:
* * * * * * *

	SelectSent = 'SELECT MSG_GROUPS WITH ENTRY_ID = ':QUOTE(@USER4):' BY GROUP_NAME'

	RList(SelectSent,TARGET_ACTIVELIST$, '', '', '' )

	IF @RECCOUNT THEN
	   
		GroupNames = Popup(@WINDOW,'','SHOW_GROUP_NAMES')
		
		IF GroupNames NE '' THEN
		
			LOCATE 'ALL_ACTIVE_USERS' IN GroupNames USING @VM SETTING Pos THEN
				NewSendToIDs = obj_Notes('AllActiveUsers')
			END ELSE
				NewSendToIDs = XLATE('MSG_GROUPS',GroupNames,'USER_IDS','X')
			END
			
			IF NewSendToIDs NE '' THEN
				GOSUB AddSendToIDs
			END

		END
			
	END ELSE
	  
	  ErrMsg('You do not have any group names...')
	  
	END

RETURN


* * * * * * *
CopyYourSelfClick:
* * * * * * *

	NewSendToIDs = ''

	GOSUB AddSendToIDs

RETURN


* * * * * * *
AllActiveUsersClick:
* * * * * * *

	Check = Msg(@WINDOW,'','CC_ALL_USERS')

	IF Check = CHAR(27) THEN RETURN

	NewSendToIDs = obj_Notes('AllActiveUsers')

	Set_Property(@WINDOW:'.SEND_TO','ARRAY','')

	GOSUB AddSendToIDs

RETURN


* * * * * * *
AllUsersClick:
* * * * * * *

	NewSendToIDs = Popup(@WINDOW,'','USER_ID')

	IF NewSendToIDs = CHAR(27) THEN RETURN

	GOSUB AddSendToIDs

RETURN


* * * * * * *
AddSendToIDs:
* * * * * * *

	SendToArray 	= Get_Property(@WINDOW:'.SEND_TO','ARRAY')
	RawSendToIDs	= SendToArray<COL$ST_ID>

	SendToCnt = 0
	SendToIDs = ''

	TestCnt = COUNT(RawSendToIDs,@VM) + (RawSendToIDs NE '')
	FOR I = 1 TO TestCnt
		IF RawSendToIDs<1,I> NE '' THEN
			SendToIDs<1,-1> = RawSendToIDs<1,I>
			SendToCnt += 1
		END
	NEXT I

	NewCnt = COUNT(NewSendToIDs,@VM) + (NewSendToIDs NE '')

	FOR I = 1 TO NewCnt
		NewSendToID = NewSendToIDs<1,I>
		LOCATE NewSendToID IN SendToIDs BY 'AL' USING @VM SETTING Pos ELSE
			SendToIDs = INSERT(SendToIDs,1,Pos,0,NewSendToID)
		END
	NEXT I

	SendToYourself = Get_Property(@WINDOW:'.COPY_YOURSELF','CHECK')

	Myself = @USER4

	LOCATE Myself IN SendToIDs BY 'AL' USING @VM SETTING Pos THEN
		IF SendToYourSelf = 0 THEN SendToIDs = DELETE(SendToIDS,1,Pos,0)
	END ELSE
		IF SendToYourSelf = 1 THEN SendToIDs = INSERT(SendToIDs,1,Pos,0,Myself)
	END

	SendToIDs := @VM	;* BlankLine on end

	SendToArray<COL$ST_ID> = SendToIDs
	Set_Property(@WINDOW:'.SEND_TO','DEFPROP',SendToArray)
	Send_Event(@WINDOW:'.SEND_TO','CALCULATE',COL$ST_NAME)

RETURN


* * * * * *
Reply:
* * * * * *

	Ctrls  = @WINDOW:'.MESSAGE':@RM			; Props  = 'DEFPROP':@RM
	Ctrls := @WINDOW:'.SUBJECT':@RM			; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.FROM':@RM			; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.SEND_TO':@RM			; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ATTACH_WINDOW':@RM	; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ATTACH_KEY':@RM		; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ENTRY_ID':@RM		; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ENTRY_DATE':@RM		; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ENTRY_TIME'			; Props := 'DEFPROP'

	Vals = Get_Property(Ctrls,Props)

	Message			= Vals[1,@RM]
	Subject			= Vals[COL2()+1,@RM]
	FromID			= Vals[COL2()+1,@RM]
	SendTo			= Vals[COL2()+1,@RM]
	AttachWindow	= Vals[COL2()+1,@RM]
	AttachKey		= Vals[COL2()+1,@RM]
	EntryID			= Vals[COL2()+1,@RM]
	EntryDate		= Vals[COL2()+1,@RM]
	EntryTime		= Vals[COL2()+1,@RM]


	EntryDate = OCONV(Date(),'D2/')			;* JCH 7/15/2010
	EntryTime = OCONV(Time(),'MTH')			;* JCH 7/15/2010

	SWAP @TM WITH @TM:'>' IN Message

	Subject = 'RE: ':Subject
	Message = CRLF$:CRLF$:'>':Message

	Set_Property(@WINDOW,'SAVEWARN',0)
	Send_Event(@WINDOW,'CLEAR',0,1,1)

	IF EntID = 'NOTE_MESSAGE.REPLY_ALL' THEN
		Set_Property('NOTE_MESSAGE.SEND_TO','DEFPROP',SendTo)
		NewSendToIDs = FromID
		GOSUB AddSendToIDs
		Set_Property(@WINDOW:'.FROM','DEFPROP',@USER4)
	END ELSE
		Ctrls  = @WINDOW:'.FROM':@RM	; Props  = 'DEFPROP':@RM	; Vals  = @USER4:@RM
		Ctrls := @WINDOW:'.SEND_TO'		; Props := 'DEFPROP'		; Vals := FromID
		Set_Property(Ctrls,Props,Vals)
	END

	SeqNo = NextKey('NOTES')
	Set_Property(@WINDOW:'.SEQ','DEFPROP',SeqNo)

	Ctrls  = @WINDOW:'.MESSAGE':@RM			; Props  = 'DEFPROP':@RM	; Vals  = Message:@RM
	Ctrls := @WINDOW:'.SUBJECT':@RM			; Props := 'DEFPROP':@RM	; Vals := Subject:@RM
	Ctrls := @WINDOW:'.ATTACH_WINDOW':@RM	; Props := 'DEFPROP':@RM	; Vals := Attachwindow:@RM
	Ctrls := @WINDOW:'.ATTACH_KEY':@RM		; Props := 'DEFPROP':@RM	; Vals := AttachKey:@RM
	Ctrls := @WINDOW:'.ENTRY_ID':@RM		; Props := 'DEFPROP':@RM	; Vals := EntryID:@RM
	Ctrls := @WINDOW:'.ENTRY_DATE':@RM		; Props := 'DEFPROP':@RM	; Vals := EntryDate:@RM
	Ctrls := @WINDOW:'.ENTRY_TIME'			; Props := 'DEFPROP'		; Vals := EntryTime

	Set_Property(Ctrls,Props,Vals)

	Send_Event(@WINDOW:'.FROM_NAME','CALCULATE')
	Send_Event(@WINDOW:'.ENTRY_ID_NAME','CALCULATE')
	Send_Event(@WINDOW:'.SEND_TO','CALCULATE',COL$ST_NAME)

	IOOptions = Get_Property( @WINDOW, 'IOOPTIONS' )

	IOOptions<2> = 0 ;* do the lock creating a new reply	another WTFO??????

	Set_Property( @WINDOW, 'IOOPTIONS', IoOptions )


	Set_Property(@WINDOW:'.SEND','ENABLED',1)
	Set_Property(@WINDOW:'.REPLY','ENABLED',0)
	Set_Property(@WINDOW:'.REPLY_ALL','ENABLED',0)
	Set_Property(@WINDOW:'.FORWARD','ENABLED',0)
	Set_Property(@WINDOW:'.MENU.FILE.SAVE_ROW','ENABLED',1)
	Set_Property(@WINDOW:'.MESSAGE', "FOCUS", 1)

RETURN


* * * * * * *
Forward:
* * * * * * *

	Ctrls  = @WINDOW:'.MESSAGE':@RM			; Props  = 'DEFPROP':@RM
	Ctrls := @WINDOW:'.SUBJECT':@RM			; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.FROM':@RM			; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.SEND_TO':@RM			; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ATTACH_WINDOW':@RM	; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ATTACH_KEY':@RM		; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ENTRY_ID':@RM		; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ENTRY_DATE':@RM		; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.ENTRY_TIME'			; Props := 'DEFPROP'

	Vals = Get_Property(Ctrls,Props)

	OrgMessage		= Vals[1,@RM]
	Subject			= Vals[COL2()+1,@RM]
	FromID			= Vals[COL2()+1,@RM]
	SendTo			= Vals[COL2()+1,@RM]
	AttachWindow	= Vals[COL2()+1,@RM]
	AttachKey		= Vals[COL2()+1,@RM]
	EntryID			= Vals[COL2()+1,@RM]
	EntryDate		= Vals[COL2()+1,@RM]
	EntryTime		= Vals[COL2()+1,@RM]

	SWAP @TM WITH @TM:'>' IN OrgMessage

	SendToUserIDs = SendTo<COL$ST_ID>
	SWAP @VM WITH ', ' IN SendToUserIDs

	Subject = '[FW: ':Subject:']'

	Message  = CRLF$:CRLF$
	Message := '--------- Original Message ---------':CRLF$:CRLF$
	Message := 'Subject: ':Subject:CRLF$
	Message := '   Date: ':OCONV(EntryDate,'D4/'):' ':OCONV(EntryTime,'MTS'):CRLF$
	Message := '   From: ':FromID:CRLF$
	Message := '     To: ':SendToUserIDs:CRLF$
	Message := CRLF$:CRLF$

	Message := CRLF$:CRLF$:'>':OrgMessage

	Set_Property(@WINDOW,'SAVEWARN',0)
	Send_Event(@WINDOW,'CLEAR',0,1,1)

	IF EntID = 'NOTE_MESSAGE.REPLY_ALL' THEN
		Set_Property('NOTE_MESSAGE.SEND_TO','DEFPROP',SendTo)
		NewSendToIDs = FromID
		GOSUB AddSendToIDs
		Set_Property(@WINDOW:'.FROM','DEFPROP',@USER4)
	END ELSE
		Ctrls  = @WINDOW:'.FROM':@RM	; Props  = 'DEFPROP':@RM	; Vals  = @USER4:@RM
		Ctrls := @WINDOW:'.SEND_TO'		; Props := 'DEFPROP'		; Vals := ''
		Set_Property(Ctrls,Props,Vals)
	END

	SeqNo = NextKey('NOTES')
	Set_Property(@WINDOW:'.SEQ','DEFPROP',SeqNo)

	Ctrls  = @WINDOW:'.MESSAGE':@RM			; Props  = 'DEFPROP':@RM	; Vals  = Message:@RM
	Ctrls := @WINDOW:'.SUBJECT':@RM			; Props := 'DEFPROP':@RM	; Vals := Subject:@RM
	Ctrls := @WINDOW:'.ATTACH_WINDOW':@RM	; Props := 'DEFPROP':@RM	; Vals := AttachWindow:@RM
	Ctrls := @WINDOW:'.ATTACH_KEY':@RM		; Props := 'DEFPROP':@RM	; Vals := AttachKey:@RM
	Ctrls := @WINDOW:'.ENTRY_ID':@RM		; Props := 'DEFPROP':@RM	; Vals := EntryID:@RM
	Ctrls := @WINDOW:'.ENTRY_DATE':@RM		; Props := 'DEFPROP':@RM	; Vals := EntryDate:@RM
	Ctrls := @WINDOW:'.ENTRY_TIME'			; Props := 'DEFPROP'		; Vals := EntryTime

	Set_Property(Ctrls,Props,Vals)

	Send_Event(@WINDOW:'.FROM_NAME','CALCULATE')
	Send_Event(@WINDOW:'.ENTRY_ID_NAME','CALCULATE')
	Send_Event(@WINDOW:'.SEND_TO','CALCULATE',COL$ST_NAME)

	IOOptions = Get_Property( @WINDOW, 'IOOPTIONS' )

	IOOptions<2> = 0 ;* do the lock creating a new reply	another WTFO??????

	Set_Property( @WINDOW, 'IOOPTIONS', IoOptions )

	Set_Property(@WINDOW:'.SEND','ENABLED',1)
	Set_Property(@WINDOW:'.REPLY','ENABLED',0)
	Set_Property(@WINDOW:'.REPLY_ALL','ENABLED',0)
	Set_Property(@WINDOW:'.FORWARD','ENABLED',0)
	Set_Property(@WINDOW:'.MENU.FILE.SAVE_ROW','ENABLED',1)
	Set_Property(@WINDOW:'.MESSAGE', "FOCUS", 1)

RETURN


* * * * * * *
ViewAttachment:
* * * * * * *

	AttachWindow = Get_Property(@WINDOW:'.ATTACH_WINDOW','DEFPROP')
	AttachKey = Get_Property(@WINDOW:'.ATTACH_KEY','DEFPROP')

	IF AttachWindow NE '' AND AttachKey NE '' THEN
		obj_Appwindow('ViewRelated',AttachWindow:@RM:AttachKey)
	END

RETURN


* * * * * * *
SendToPC:
* * * * * * *

	NextColumn	= Parm1
	NextRow		= Parm2

	Forward_Event(NextColumn,NextRow)

	CurrRow = Get_Property(@WINDOW:'.SEND_TO','ROWDATA')

	CurrRow<COL$ST_NAME> = OCONV(CurrRow<1,COL$ST_ID>,'[XLATE_CONV,LSL_USERS*FIRST_LAST]')

	Set_Property(@WINDOW:'.SEND_TO','ROWDATA',CurrRow)

	GOSUB Refresh

RETURN


* * * * * * *
Print:
* * * * * * *

	PrintPath = Printer_Select('',1)	;* Get default printer

	Stat = Set_Printer( 'INIT', '', '', 1.25:@FM:'':@FM:1.0:@FM:'', 0,'',PrintPath )
	GOSUB CheckErr

	Font = "Courier New,12,L,1"
	CONVERT ',' TO @FM IN Font
	Hf = Font
	Stat = Set_Printer( 'FONT', Font )
	GOSUB CheckErr


	SendTo = Get_Property(@WINDOW:'.SEND_TO','ARRAY')

	Void = Set_Printer( 'TEXT', 'TO:' )
	Table = ''

	SendTo<1> = ex_vm_rem( SendTo<1> )
	Rcnt = COUNT(SendTo<1>,@VM) + (SendTo NE '')

	FOR I = 1 TO Rcnt
		Tvar = SendTo<2,I>:@VM:SendTo<2,I+1>:@VM:SendTo<2,I+2>
		Table<-1> = Tvar
		I = I+2					; *skip column 2 & 3 that just got appended
	next i
	Void = Set_Printer( 'ADDTABLE', '2880':@VM:'2880':@VM:'2880', '', Table, '','','', TB_ALL )
	Void = Set_Printer( 'TEXT', '' )
	Void = Set_Printer( 'TEXT', 'From: ':Get_Property(@WINDOW:'.FROM','DEFPROP'):'   ':Get_Property(@WINDOW:'.FROM_NAME','DEFPROP'))
	Void = Set_Printer( 'TEXT', '' )
	Void = Set_Printer( 'TEXT', 'Date: ':Get_Property(@WINDOW:'.ENTRY_DATE','DEFPROP'))
	Void = Set_Printer( 'TEXT', '' )
	Void = Set_Printer( 'TEXT', 'Subject: ':Get_Property(@WINDOW:'.SUBJECT'))
	Void = Set_Printer( 'TEXT', '' )
	Void = Set_Printer( 'TEXT', '                         M  E  S  S  A  G  E' )
	Void = Set_Printer( 'TEXT', '' )  
	 
	MessageText = Get_Property(@WINDOW:'.MESSAGE','DEFPROP')

	SWAP @TM WITH CRLF$ IN MessageText

	TableColInfo = '9360'
	x = Set_Printer("ADDTABLE", TableColInfo, '', MessageText, '', '', 1, TB_NONE)

	Stat = Set_Printer( 'TERM' )

	GOSUB CheckErr
	
RETURN


* * * * * * *
CheckErr:
* * * * * * *

	IF Stat < 0 THEN
		Void = msg( '', Stat )
		Stat = Set_Printer( 'TERM' )
	END

RETURN

