Bug? - FindNextElemement with RTELEM_TYPE_TABLECELL and blank cells

We’re looping through cells in a table. If the cell is blank, FindNextElement seems to skip right over that cell to the next one. How can we get access to blank cells? They need to be processed as blank, not skipped. If you have 10 cells and loop through them all with FindNextElement and only find 9 cells, which one was blank?? If I’m wrong and FindNextElement can find blank cells (not according to our testing so far), please let me know and we’ll see what else we might be doing wrong (nothing that we can see).

On a side note, how do you access the front end rich text item? We present a table in a dialog box and need to access any edits the user makes. The only way we have found is to save the document. If we could find some way to access the front end rich text item value we wouldn’t need to save the document and then clean them out afterwards - user might not have delete, so this means another agent to seek them out and destroy them at some other time. Workable but depressing :frowning:

Any ideas greatly appreciated.

Subject: found it :slight_smile:

We needed to use SetEnd on the RichTextNavigatorRange. TextParagraph was returning the blank cell, but without the SetEnd it was spilling over into the next cell. Is that a bug? I dunno, but we’re good to go now. Thanks anyway.

Subject: RE: found it :slight_smile:

It’ September 2013 and I am working with Notes / Domino r9 and have just encountered this exact same issue.

I have a LotusScript agent looping through the cells of a table in rich text field and need to extract the text from each cell. I was finding that when an empty cell was encountered the cell was ignored and I was actually getting the text from the next cell.

Adding RichTextNavigatorRange.SetEnd solved the issue as it did for Mike.

Subject: bug? - FindNextElemement with RTELEM_TYPE_TABLECELL and blank cells

I’ve used FindNextElement() to populate tables I created out of whole cloth, so I know that it won’r skip blanks. There’s got to be something else you’re doing to cause the skip.

As for front-end RT, all you really have access to is the UI field text. That is, you can’t look at the rich text structures because the content of the editor has not been saved to the rich text item.

Subject: RE: bug? - FindNextElemement with RTELEM_TYPE_TABLECELL and blank cells

I have to disagree about the UI and rich text. Technically, you are correct that you can’t manipulate the UI rich text, but that misses the point of the question asked (in my humble opinion). There are actually three images of the document: the front end, the in-memory note and the on-disk note. There is no easy way to access the front end structures, but it is easy to manipulate the in-memory note without ever saving to disk. I am not sure what the Notes classes allow, but we do this with our Midas Rich Text LSX all the time. Even with the native classes, you can close and reopen the document, manipulating the rich text before reopening, which avoids the save problem since it never updates the on-disk note (in fact, there isn’t an on-disk note yet for a new document).

I hope I made that a bit clearer. There is a document Andre (from IBM) has that shows how to do this with the native classes, I’m pretty sure. It is more cumbersome than with Midas, but still possible.

Subject: RE: bug? - FindNextElemement with RTELEM_TYPE_TABLECELL and blank cells

Agreed – I read “UI” and assumed “from the UI” (as opposed to examining the in-memory note with the document closed).

Subject: front end rich text

We put up a temporary unsaved document in a dialog box. It has a 2 column table with any number of rows. The user can edit the contents of the table. When the user clicks our OK button, we need to act on the values that the user may have edited, and not the original values that we presented. In our OK button, when we access the rich text field, it contains the original values. The only way we found to access any edits the user might have made is to save the document.

I was aware of the difference between the on-disk and the front end. I know that on a normal form I could have a button that would manipulate the rich text in the back end, and that closing and reopening would be the only way to get the back end changes to show on screen (now there is the Update function for that - yay!). In this situation we want to go in the opposite direction - through the back end access changes the user has made in the front end, instead of present back end changes we made to the user in the front end. Does that sound dirty?!

I did find this:

It explains a lot, but doesn’t help in this situation. Anyway, we have this working now too, saving isn’t catastrophic. Was just looking for something more elegant. Thanks for the help guys.

Subject: FindNextElemement

Here’s the code (we have a table with 2 columns and ctr rows, it’s the second column we’re interested in hence the Mod 2):

Do

rtrangeCell.SetBegin rtnavBody

rtrangeCell.SetEnd rtNavBody

Set rtnavCell = rtrangeCell.Navigator

If counter Mod 2 = 1 Then

	If ctr = 0 Then

		Redim arrValues(0)

		Redim arrNumbers(0)

	Else

		Redim Preserve arrValues(ctr)

		Redim arrNumbers(ctr)

	End If

	arrValues(ctr) = rtRangeCell.TextParagraph

	ctr = ctr + 1

End If

counter = counter + 1

Loop While rtnavBody.FindNextElement(RTELEM_TYPE_TABLECELL)

Without the bolded line, if one of the cells contained no text, it seems to skip right over the blank cell. arrValues ended up one value short - where the blank was supposed to be, there was the next cell’s value instead. Adding the SetEnd fixed it up - so we assume it was spilling over and reading the next cell? I don’t know, it was someone else’s code, I was just trying to help. Could that be a bug with TextParagraph? Or would you expect that behaviour? I admit I haven’t spent any time testing it out, it works now so I’m happy :wink: