logo

New Response

« Return to the blog entry

You are replying to:

  1. Jake, I'm sure you meant Mark.

    For all the ones who need to write the HTML inside LotusScript (e.g. I'm using it after I've read a whole web page into memory), the following subroutine could help. It safely inserts a paragraph after 7000 characters after the next '>' character. Use at your own risk (has been only marginally tested).

    Sub SaveHTMLToRTItem(rnrti As NotesRichTextItem, rstr_HTML As String)

    %REM

    This is a workaround for the following Domino bug:

    "AppendText method of LotusScript inserts carriage returns into RichText item"

    {Link}

    If the carriage return is inserted in the middle of an HTML tag, the HTML breaks.

    This sub will break up the HTML into chunks of 7000 characters, look for the next

    closing tag '>' and then append a new line.

    The parameter rstr_HTML has been passed by reference in ordrer to avoid

    copying large amounts of data in memory.

    %END REM

    Dim lng_Pos As Long

    Dim lng_PosOld As Long

    Const lng_CHUNK_LENGTH = 7000&

    lng_Pos = Instr(lng_CHUNK_LENGTH, rstr_HTML, ">")

    If lng_Pos = 0 Then

    rnrti.AppendText(rstr_HTML)

    rnrti.AddNewline(1)

    Else

    lng_PosOld = 0

    Do Until lng_Pos = 0

    rnrti.AppendText(Mid$(rstr_HTML, lng_PosOld + 1, lng_Pos - lng_PosOld))

    rnrti.AddNewline(1)

    lng_PosOld = lng_Pos

    lng_Pos = Instr(lng_Pos + lng_CHUNK_LENGTH, rstr_HTML, ">")

    Loop

    rnrti.AppendText(Mid$(rstr_HTML, lng_PosOld + 1))

    rnrti.AddNewline(1)

    End If

    End Sub

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: