addText to TextArea in RTF-Format

I am trying to compile a text to a TextArea from various lines in an Array. The TextArea formatted as styledText.RTFData. My nonworking tryout:

var ST as new StyledText
for rCount=0 to  mTitleArray.Count-1
  
  ST.RTFData = mTitleArray(rCount,0)+chr(9)+mTitleArray(rCount,1)+chr(9)+mTitleArray(rCount,2)+EndOfLine+EndOfLine
  TextArea1.addText = ST
  
next

But with this code, Xojo is wining:
This method cannot accept an assigned value (it lacks an Assigns parameter).
TextArea1.addText = ST

Can someone help me out here, pleae?

Remove the “=“

Thanks Paul. That gives out the issue:

Parameter “text” expects type String, but this is class StyledText.
TextArea1.addText ST

I’ve also tried:

for rCount=0 to  mTitleArray.Count-1
 TextArea1.addText(mTitleArray(rCount,0)+chr(9)+mTitleArray(rCount,1)+chr(9)+mTitleArray(rCount,2)+EndOfLine+EndOfLine)
next
TextArea1.StyledText.RTFData = TextArea1.Value

But that ends up in a blank screen…

RTF format being something like

{\rtf1\ansi\ansicpg1252{\fonttbl{\f0\fnil .AppleSystemUIFont;}}{\colortbl\red0\green0\blue0;}\uc0 \f0\fs26 Hello XOJO}

I don’t think you can add text like that.

That makes sense and would speak for my second solution. The question there is, how do you transform plain text to RTF in the TextArea?

you set textarea.text = “myplaintext” and then in the textarea.styledtext.rtfdata you get the converted rtf.

I don’t understand what type of string/data you have and what you want to do with it !

What I wanted to illustrate is, that the text is an addition of several separate lines. They are stored in an Array. Could also be a Listbox, that does not matter. So I use the TextArea.addText command to assemble the lines.

What you say is interesting, but I just don’t know how to do it, if I have:

how I then am able to convert the plain text into RTFData-Text?

for rCount=0 to  mTitleArray.Count-1
  
  TextArea1.addText mTitleArray(rCount,0)+chr(9)+mTitleArray(rCount,1)+chr(9)+mTitleArray(rCount,2)+EndOfLine+EndOfLine
  
next

should do what you want. no need to use the RTFData property.

But that way, when I later try to read TextArea1.StyledText.RTFData I get a beach ball turning on macOS, the app crashes…

how many lines do you add to the textarea ? textarea is known to become very slow if you have too many lines…

That depends on the file a user wants to open… can’t say exactly how many lines. But so far the app could handle, what I have been working with… That is not the issue, I guess.

what is the order of magnitude ? 10s, 100s, 10000s lines ?

I don’t know, why you keep asking this. But if you will, approx 10 to 1000 lines…

with 1000 lines, the textarea will become very slow.
but if you test with 10 lines it should respond immediately.
so your hang problem lies somewhere else.

As I wrote before, this is not the issue here. The app crashes also with three lines. The problem seems to be, that The TextArea does not contain RTFData. So my question remains, how do you make a TextArea that is filled with plain Text RTF formatted? Or am I making a mistake in reading out the TextArea which is something like:

system.DebugLog "TextArea1 = "+TextArea1.StyledText.RTFData

?

what does textarea1.text output ?

I have made a small utility that converts text to rtf text, and it is as simple as you’re doing !
so I would like to understand what kind of plain text can make this hang ?

That does output all the plain text. (Thanks for keeping on it!)

TextArea1.StyledText.RTFData = "a single line"
system.DebugLog "TextArea1 = "+TextArea1.Text

This outputs: TextArea1 =
So blank. Why? How to fix that?

TextArea1.StyledText.RTFData = "{\rtf1\ansi\ansicpg1252{\fonttbl{\f0\fnil .AppleSystemUIFont;}}{\colortbl\red0\green0\blue0;}\uc0 \f0\fs26 a single line}"
system.DebugLog "TextArea1 = "+TextArea1.Text

this is what rtf looks like.