I have some code that runs perfectly when the debugger is on, but fails to produce the same desired result in a editable rich text field when it is off. It does not matter whether the document is in edit mode or not. There are no error messages, all user info, prints to the status bar, messageboxes display fine, but a rich text field is changed (after reopening) when the debugger is on and not changed when it is not.
What I am trying to do with this LotusScript action is to parse the RichTextField looking for computed text elements in the NotesRichTextField and changing their formulas. I do this by using CreateDXLExporter, and CreateDOMParser to a NotesStream, Serialzing the Parser and then using CreateDXLImporter with the stream as input to bring the modified computed text elements in the NotesRichTextField back into the document. Whew. Sure would be easier if there was a type for computed text fields in NotesRichTextNavigator. Anybody any thoughts on alternative ways to do this or why this works when debugging and not otherwise?
Subject: RE: Code works when Debugger running - fails when debugger not running
It could be the scope of your variables.
I’ve had this in the past where I’d written a function to return a RTItem, I created a temp doc inside the function. If I ran the code it worked in debug but not without it. It didn’t work as the doc was a local variable inside my function, when the function ends the doc, and there for my RTItem was destroyed.
I presume when running in debug the destructor doesn’t work the same way.
Subject: RE: Code works when Debugger running - fails when debugger not running
It’s been my preferred approach to pass the NotesDocument in and out through my function properties. That way, what is returned is what is submitted altered in some way. It’s not that bad in terms of memory usage unless you start to move around a bunch of file attachments in your RT fields and I find it much easier to follow the data flow and track my desired outcome.
Subject: RE: Code works when Debugger running - fails when debugger not running
I was going to suggest the same thing, actually. I’ve been working with some rich text myself the last couple of days and there is a strange timing issue to getting the fields to update properly.
I solved my problem by updating the NotesRichTextItem in memory, deleting it off the document, putting it back onto the document, closing the NotesUIDocument, then reopening the NotesUIDocument. Andre Guirard documents most of that technique here: http://www-10.lotus.com/ldd/nd6forum.nsf/0/dd507a5be7cc2e4285256eec005f56ef