COMPILE SUBROUTINE Create_Note( SendTo, SentFrom, Subject, Message, AttachWindow, AttachKeys, SendToGroupName ) DECLARE FUNCTION Next_Key, Msg, FieldCount DECLARE SUBROUTINE Record_Lock, obj_Notes_Sent $INSERT LOGICAL $INSERT NOTES_EQU $INSERT NOTE_PTRS_EQU StCnt = FieldCount( SendTo, @VM ) HoldSendTo = SendTo NewSendTo = '' * LET'S STRIP OFF THE DUPLICATE NAMES FOR I = 1 TO StCnt ThisSendTo = SendTo<1,I> LOCATE ThisSendTo IN NewSendTo USING @VM SETTING DPos ELSE NewSendTo<1,-1> = ThisSendTo END NEXT I TRANSFER NewSendTo TO SendTo * IF ASSIGNED( SendToGroupName) ELSE SendToGroupName = '' * the only intent of the group parameter is for traceability for the sender * group names will be hidden on the read if you are not the owner * any system generated message will not pass this parameter * notes and notes_attach will do its own stripping of dups END OPEN 'NOTES' TO NotesTable ELSE Void = msg( '', 'Unable to open NOTES...' ) RETURN END OPEN 'NOTE_PTRS' TO NotePtrTable ELSE Void = Msg( '', 'Unable to open NOTES_PTRS...' ) RETURN END NextNoteKey = next_key( 'NOTES', NotesTable, 'NEXT', '' ) NoteRec = '' NoteRec = 'I' NoteRec = date() NoteRec = time() NoteRec = SendTo NoteRec = SentFrom NoteRec = Message NoteRec = @user4 NoteRec = Subject NoteRec = AttachWindow NoteRec = AttachKeys NoteRec = SendToGroupName WRITE NoteRec ON NotesTable, NextNoteKey ELSE void = Msg( '', 'Unable to write ':NextNoteKey:' on NOTES...' ) RETURN END UNLOCK NotesTable, NextNoteKey ELSE Void = msg( '', 'Unable to unlock ':NextNoteKey:' on NOTES...' ) RETURN END Void = Next_Key( 'NOTES', NotesTable, 'UPDATE', NextNoteKey ) Attachment = 'No' IF AttachWindow AND AttachKeys THEN Attachment = 'Yes' FOR I = 1 TO StCnt ThisSendTo = SendTo<1,I> IF LEN(ThisSendTo) THEN Recipient = ThisSendTo NoteID = NextNoteKey CurrDTM = OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTHS') obj_Notes_Sent('Create',Recipient:@RM:NoteID:@RM:CurrDTM) END NEXT I