Possible BUG: notesitem.text <> str when contains chr$(10)

The following example writes a string containing chr$(10) to a field in a new document, the second time its run it finds the previous document and compares the string.

The original contains one chr$(10) but the notesitem.text contains two chr$(10)… Why - is this a bug ?

Anybody got a workaround ? (I’ve tried doc.replaceitamvalue(“fieldname”, str) and notesdoc.itemname = str, both with the same result).

note Notes 6.5.4 debugger does not show the chr$(10) in the str but Notes 6.5.5 does.

example code:

'a string compare test!:

Option Public

Option Declare

Dim session As NotesSession

Dim thisdb As notesdatabase

Dim collection As NotesDocumentCollection

Dim thisdoc As notesdocument

Dim datetime As notesdatetime

Dim searchFormula As String

Dim strSource As String

Dim strDestination As String

Dim item As notesItem

Sub Initialize

Set session = New notessession

Set thisdb = session.CurrentDatabase



Set datetime = New notesdatetime ("1/1/2007")

searchFormula = {Form = "atestform"}



Set collection = thisdb.Search (searchFormula, datetime,1)	

Set thisdoc = collection.GetFirstDocument



strSource = "this is a test string with a chr$(10) charector" & Chr(10) & "in it"



If collection.count = 1 Then

	Set item = thisdoc.GetFirstItem ("strTest")

	strDestination = item.Text

	

	If strSource <>strDestination Then

		Print strSource

		Print strDestination

’ Call thisdoc.ReplaceItemValue (“strTest” , strSource)

		thisdoc.strTest = strSource

		Call thisdoc.save (True,False)

	End If

	

Else

	Set thisdoc = New NotesDocument (thisdb)

	Call thisdoc.replaceitemvalue ("Form" , "atestform")

	Call thisdoc.replaceitemvalue ("strTest", strSource)

	Call thisdoc.Save (True,False)

End If

End Sub

Subject: possible BUG: notesitem.text <> str when contains chr$(10)

I came across this a while ago when using the return button in a text field and found that notes stores it internally as a carriage return and line feed - Chr(13) then Chr(10).

You could use the replace function to strip out all of these before comparing the strings.