RTFData and Windows – anything new?

For now I finished the note taking app I mentioned in another post. Everything works very quickly and fluently on macOS. Then I tried the Windows version for the first time, and everything ran as expected – except that loading RTFData to a text area is even slower than I had remembered.
On macOS even styled documents with 10.000 words and more load in an instant (thanks to some declares), whereas Windows needs a noticable amount of time when loading styled documents only of less than 1.000 words.
I could improve loading speed by setting TextArea1.Text = “” before loading the new RTFData, but the result is still unacceptable in comparison to the macOS version.

So are there any news (or new workarounds) concerning RTFData speed on Windows?

You could use TextArea.WinRTFDataMBS with my MBS Plugins.


Since programming is just a hobby for me I have tried to avoid extra costs. But I work with RTF data a lot and it causes me a lot of troble, so in this case I might be tempted some day…

Is this stored data only for use within you own app?
If so, you might want to try another format, such as storing the styleruns in some manner instead

I only worked with styleruns once, but I remember them to be rather slow. And since RTF works fine on macOS I’d rather not change the hole format (which surely would bring new problems with it).

Besides: Is this forum some kind of broken? I read the thread about Norman’s missing posts; and yesterday I saw in the overview, that Michel Bujardet postetd something here in this thread, but when I clicked in the thread, there was no post by him to read (and still isn’t)…

I did post about Formatted Text Control, then realized the OP did not want any third party tool, so deleted by post. Mystery solved, Jens :wink:

About RTFData loading, given the fact that RTFData loading becomes infinite past a certain size, any stylerun solution will be faster.

That’s sad, because on macOS it is so nice and easy…
So then I will give styleruns some thinking.

I’m currently looking at styled text handling myself, and it seems to be a mess …

You might see code snippets using SetTextAndStyle but keep in mind that SetTextAndStyle had been removed …

How about using html instead? But then you would need one of the html editor things which again would cost money.

I solved the issue I had with my CheckWriter III+ app with Bkeeney’s Formatted Text Control, which is flawless on both platforms. https://www.bkeeney.com/formatted-text-control/

It is not that expensive, and it has many features not found in the regular TextArea.

@Michel: “Not that expensive” depends on what you are aiming at – just for the fun of it is just too much for me.

During a free hour I toyed around with an own module (and two associated custom classes) in order to save the styled text and load it back to a text area (by now without keeping paragraph alignment). Saving – not as RTF but in my own “file format” – is about 2 to 100 times faster, depending on text length and number of style runs. But the main problem is unsolved yet: loading data to a text area with my method can be up to 5 times faster than Xojo’s RTFData, but longer and heavily formatted texts are loading almost as slowly as RTFData, so there is no advantage. In addition to that I would lose the opportunity to exchange note files between Mac and Windows versions if I changed the Windows version from RTF to my own file format (and RTF on macOS is so fast I would not want to remove it).
So, I’m still unsure what to do with it…

If you devise a viable alternative storage method… why would you not use it on both macOS and Windows versions?

RTF is an antique format to say the least, and unless you need to share your data with an external 3rd party app (Word for example) then why bother with it… Heck Microsoft has even moved past RTF and it is only still available as an option for legacy purposes.

What I would do is alter you database structure, and instead of storeing the “note” in ONE field (which I assume is what you are doing), I would store it in a related table with a key to tie it to the master record, and one record for EACH style run… this way there is no translation, compression required… and the textfield can be loaded and unloaded directly via SQL, which should be very fast

noteKey INTEGER,
font  TEXT,
textColor TEXT,
underline BOOLEAN)

textcolor would be stored as STR(color) since there is no COLOR datatype

That’s an interesting approach. It’s nothing I am able to test in a few minutes or hours, but I will keep it in mind and think about it…
How exactly would you load the data to the text area? Is creating StyleRuns with the database values and appending them to a StyledText what you mean?

Until now I stuck to RTF only because it was very convenient, and on macOS I can load styled texts of 10.000 or more words in less than 50 milliseconds. But regarding the problems I have with Windows and RTF maybe it is time to move on indeed.

Price is related to what you do with the software. I do sell CheckWriter III+ on the MAS, on my own site, on Amazon and on the Windows Store. Then really the price of TFC is negligible. For professionals, wasting time reinventing the wheel is the worst waste of time.

If it ain’t broke, don’t fix it. For Mac, I would not try to second guess RTF indeed.

It is easy with an if TargetWindows to know when to switch to another method.

I get your point, but as I said I am not a professional – and “reinventing the wheel” is a great way of learning for me. :slight_smile:

In the meantime I gave Dave’s approach a first try. It works quite well for short texts, but larger documents give me a beach ball that spins for a very long while…

Jens… do you have a test project?
if so, send it to me… I’d be interested to see how optimize it…

One thing… set TextArea Enabled to FALSE before you load it

Maybe the use of ‘transaction’ in sqlite could help boost the speed.

BTW @Dave S i find the use of sqlite for this purpose a very nice idea!

@Andre: I’m using transactions and prepared statements. I don’t think that the datababase is the problem, but my routine to set together the style runs.

@Thanks for the offer! I will send you private note…

Styled text on Windows is notoriously slow. The problem isn’t RTF specific, so you’re going to have slowness on Windows no matter what you do. Unless you resort to a plugin, what you got is probably the best you’re going to get.