BlogSphere V3OpenDocument[/Projects/pmt.nsf/ProjectView?ReadForm&Query=]

Project: BlogSphere V3 (Managed by )
 | The bugBug ID: NOSS-6ZCT39
| Submitted by: | Thomas Bahn |
| Project Master Chef: | Declan Lynch |
| Bug type: | Functionality |
| Brief Description: | Print statement is limited to 64 KB |
| Severity: | Medium |
| Version | 3.0.1 B6 |
| Status: | |
By increasing the number of entries in our RSS feed, I have encountered a limit in the Print statement of LotusScript. Although strings can be as large as 2 GB, Print only prints the first 64 KB (or reacts unpredictable).
To avoid this limit, printing of string which could get larger than 64 KB should be done by sub, which divides the string to be printed in chunks smaller than 64 KB.
I have written such a sub:
Public Sub PrintHTMLInChunks(htmlString As String)
'/**
' * prints given htmlString in chunks with length lower than 64K.
' *
' * In Notes R5 (?) we have gotten strings that can grow up to 2 GB in size. But even in Notes 7 the Print command seems to be limited to 64 KB.
' *
' * Since every Print appends a new line character (or two on Windows) to the string printed, we cannot simply break longer strings at every position, but only at whitespaces.
' * For the sake of simplicity, I only look for space, LF and CR characters, which should be quite frequent in HTML sources.
' *
' * @param htmlString string containing HTML source code to be printed.
' *
' * @author Thomas Bahn <tbahn@assono.de>
' * @version 2007-03-16
' */
Const MAX_CHUNK_SIZE = 65000
Dim length As Long
Dim startPosition As Long
Dim endPosition As Long
Dim charAtEndPosition As String
length = Len(htmlString)
startPosition = 1
' separate htmlString in chunks and print them
Do
endPosition = startPosition + MAX_CHUNK_SIZE
If endPosition > length Then ' we reached the last chunk
Print Mid$(htmlString, startPosition)
Else
' find position of last whitespace (space, LF or CR) in htmlString
charAtEndPosition = Mid$(htmlString, endPosition, 1)
Do Until (charAtEndPosition = Chr$(32) Or charAtEndPosition = Chr$(10) Or charAtEndPosition = Chr$(13)) Or endPosition = startPosition
endPosition = endPosition - 1
charAtEndPosition = Mid$(htmlString, endPosition, 1)
Loop
If endPosition = startPosition Then ' no space, LF nor CR found (in 64 KB of HTML source!)
endPosition = startPosition + MAX_CHUNK_SIZE ' just use MAX_CHUNK_SIZE
End If
Print Mid$(htmlString, startPosition, endPosition - startPosition + 1) ' print this chunk
startPosition = endPosition + 1
End If
Loop Until endPosition >= length
End Sub
Then I have modified Sub Initialize in "stories.xml" agent by replacing
Print RenderEngineRSSEntries()
by
Call PrintHTMLInChunks(RenderEngineRSSEntries())
This replacement should be done everywhere, where the string could get very large. |
 |
 |  |
| Status: | Fixed |
| Implemented in Release: | 3.0.1 B7 |
| Fix Details: |  |
|
Modification history
| Entered 16-Mar-2007 16:21 by Thomas Bahn. Last Modified 07-Aug-2007 10:41 by Declan Lynch. |
Feedback
Check out other projects