COMPILE ROUTINE FIX_NOTE_PTRS(Dummy)
ROWDEF (CHARSTR)

DECLARE SUBROUTINE SEND_INFO, SEND_DYN, RList

$INSERT NOTES_EQU
$INSERT NOTE_PTRS_EQU



OPEN "NOTES" TO TableIn ELSE
	Send_Info('Puked on table open')
	GOTO Bail
END


OPEN 'NOTE_PTRS' TO PtrFile ELSE DEBUG

READ Rec FROM PtrFile,'CAROL_H' THEN
	Rec<1> = FIELD(Rec<1>,@VM,1,11)
	debug
	WRITE Rec ON PtrFile,'CAROL_H' THEN NULL
END

a = XLATE('NOTE_PTRS','CAROL_H','','X')

DEBUG


GOTO Bail





SelectSent = 'SELECT NOTES WITH SEND_TO "JOHN_N" AND WITH ENTRY_DATE > "8/12"'

RList(SelectSent,5,'','','')


READ NPRec FROM PTrFile,'JOHN_N' THEN

	RecCnt = 0
	Done = 0
	LOOP
		READNEXT NoteNo ELSE Done = 1
	UNTIL Done
		READ NoteRec FROM TableIn,NoteNo THEN
			*IF NoteRec<4> = 'JOHN_N' THEN
				Subject = NoteRec<18>
				SentFrom = NoteRec<5>
			
				NPRec = INSERT( NPRec, note_ptrs_subject$, 1, 0, NoteRec<18> )		;* Add the subject
				NPRec = INSERT( NPRec, note_ptrs_from$, 1, 0, NoteRec<5> )
				NPRec = INSERT( NPRec, note_ptrs_date$, 1, 0, OCONV( NoteRec<2>,'D2/') )
				NPRec = INSERT( NPRec, note_ptrs_time$, 1, 0, OCONV( NoteRec<3>,'MTH') )
				NPRec = INSERT( NPRec, note_ptrs_new$, 1, 0, 'Yes' )
				NPRec = INSERT( NPRec, note_ptrs_note_ids$, 1, 0, NoteNo )
				IF NoteRec<19> NE '' AND NoteRec<20> NE '' THEN
					Attachment = 'No'
				END ELSE
					Attachment = 'Yes'
				END
				NPRec = INSERT( NPRec, note_ptrs_attachment$, 1, 0, Attachment )
			*END
		END
	REPEAT
	WRITE NPRec ON PTrFile,'JOHN_N' ELSE NULL
END 

* * * * * * *
Bail:
* * * * * * *

END
