Im trying to put the text that i have saved in a .RTF document on a text area for license purposes and it seems that i cannot make it , i guess im doing something wrong.
On the text Area MultiLine is enabled, Styled text as well enabled.
Code is the following :
[code]dim ti As TextInputStream
dim RecordText As New StyledText
dim fi As FolderItem
dim fiPath As String
fi = app.ExecutableFile.Parent.Parent.Child(“Resources”).Child(“eula_fr.rtf”)
If fi.Exists AND fi <> Nil Then
fiPath = fi.NativePath
dim tString As String
ti = TextInputStream.Open(fi)
tString = ti.ReadAll
RecordText.RTFData = tString
ti.Close
me.StyledText.RTFData = RecordText
End If[/code]
So far for test purposes i get the data on the tString , with all the RTF Encodings but nothing on the Text Area Text , it comes empty .
Thank you Michel but i dont get anything from there honestly . I looked on the forum for samples and ways to read .rtf files and to show them styled on the text area as i read that it is possible but no luck, i guess if i still dont manage to get it then i will do a .html document and an html viewer and that`s it .
Look. I have been using that technique for years. Your error is to insist on a separate styledtext variable. Just shove the RTFData string from the disk into your TextArea.StyledText.RTFData. BTW are you sure of eula_fr.rtf ? Have you opened it with a word processor ? Does it actually contain what you think it does ?
fi = app.ExecutableFile.Parent.Parent.Child(“Resources”).Child(“eula_fr.rtf”)
If fi.Exists AND fi <> Nil Then
ti = TextInputStream.Open(fi)
me.StyledText.RTFData = ti.ReadAll
ti.Close
End If[/code]
So maybe i`m getting this wrong, if i throw the ti.readall data into a string i get the data, if i put it into the me.StyledText.RTFData it comes empty on the form.
where is this code located?
are you sure the reference to “ME” is the correct textarea? (because that is the first place I’d look)
and otherwise, Michel is quite correct, there is no reason to jump through hoops…
but you need to insure the textarea you are “loading” is the same textarea you expect to see
AND there is nothing in between that UNDOES what you did (that has bitten me an unknown number of times)
[quote=329485:@Dave S]
me.StyledText.RTFData = ti.ReadAll
where is this code located?
are you sure the reference to “ME” is the correct textarea? (because that is the first place I’d look)
and otherwise, Michel is quite correct, there is no reason to jump through hoops…
but you need to insure the textarea you are “loading” is the same textarea you expect to see
AND there is nothing in between that UNDOES what you did (that has bitten me an unknown number of times)[/quote]
Hi Dave, Into the Open Event of the TextArea
Here is what I did in a small test project, with my own User license file created in TextEDit. Works flawlessly.
[code]Sub Open() Handles Open
dim f as folderItem = SpecialFolder.Documents.child(“User_License.rtf”)
If f <> Nil Then
If f.Exists Then
system.DebugLog “loading”
// Be aware that TextInputStream.Open coud raise an exception
Dim t As TextInputStream
Try
t = TextInputStream.Open(f)
t.Encoding = Encodings.MacRoman
me.styledText.RTFData = t.ReadAll
Catch e As IOException
t.Close
MsgBox(“Error accessing file.”)
End Try
End If
End If
End Sub
[/code]