OBJECT Page 50000 Custom Notes { OBJECT-PROPERTIES { Date=08/21/15; Time=[ 1:43:46 PM]; Modified=Yes; Version List=TOM HUNT; } PROPERTIES { Editable=No; InsertAllowed=No; DeleteAllowed=No; ModifyAllowed=No; SourceTable=Table2000000068; SourceTableView=SORTING(Record ID) ORDER(Descending) WHERE(Type=FILTER(Note)); PageType=List; OnAfterGetRecord=VAR TheInstream@1240060000 : InStream; RecordLink@1240060002 : Record 2000000068; NoteText@1240060001 : Text; ThisLine@1240060003 : Text; BEGIN // DisplayNote2, IntFirstChar, and NoteLength are all helpful for debugging; add them to the page display if you have issues. DisplayNote := ''; DisplayNote2 := ''; NoteText := ''; ThisLine := ''; RecordLink.GET("Link ID"); RecordLink.CALCFIELDS(Note); IF RecordLink.Note.HASVALUE THEN BEGIN RecordLink.Note.CREATEINSTREAM(TheInstream); WHILE NOT TheInstream.EOS DO BEGIN // the thing about using READTEXT is that it stops when you hit a line delimiter, and we might have a line delimiter as a // part of the note. This came up in testing. TheInstream.READTEXT(ThisLine); NoteText := NoteText + ThisLine; END; IF NoteText = '' THEN BEGIN IntFirstChar := -1; END ELSE BEGIN EVALUATE(FirstChar,COPYSTR(NoteText,1,1)); IntFirstChar := FirstChar; END; NoteLength := STRLEN(NoteText); DisplayNote2 := NoteText; DisplayNote := FormatDisplayNote(NoteText); END; END; } CONTROLS { { 1240060000;0;Container; ContainerType=ContentArea } { 1240060001;1;Group ; Name=Group; GroupType=Repeater } { 1240060004;2;Field ; Name=Note2; CaptionML=ENU=Note; SourceExpr=DisplayNote } } CODE { VAR FirstNoteShown@1240060003 : Boolean; NoteLength@1240060001 : Integer; DisplayNote@1240060000 : Text; DisplayNote2@1240060002 : Text; FirstChar@1240060004 : Char; IntFirstChar@1240060005 : Integer; PROCEDURE FormatDisplayNote@1240060001(InputNote@1240060002 : Text) FormattedNote : Text; VAR ValidCharFound@1240060000 : Boolean; CompareChar@1240060003 : Code[1]; lCounter@1240060001 : Integer; InputNoteLen@1240060004 : Integer; BEGIN FormattedNote := InputNote; InputNoteLen := STRLEN(InputNote); IF InputNoteLen <= 255 THEN BEGIN IF NOT (InputNoteLen IN [10,13]) THEN BEGIN // 10 is CR and 13 is LF; these are line delimiter characters and they'll screw up COPYSTR, // so when that happens, leave FormattedNote alone. FormattedNote := COPYSTR(FormattedNote,2); END; END ELSE BEGIN FormattedNote := COPYSTR(FormattedNote,3); END; END; BEGIN { TNH 08/20/15: Page written. } END. } }