TextArea1 open f

Hello,

I have this code in a pushbutton

Dim file as FolderItem
file = SpecialFolder.Desktop.Child(“myFile data”) // opens the file if it is in the specified location

If file <> Nil and file.exists then
Call self.TextArea1.Open(file) 'puts file contents into TextArea1
End if

It works as expected in XOJO Version 2019 Release 1
The contents of the folderitem, “myFile data”. is displayed in TextArea1

but gets this error in XOJO Version 2021 Release 3 Trial
Window1.PushButton8.Action, line 5
Type “TextArea” has no member named “Open”
Call self.TextArea1.Open(file) 'puts file contents into TextArea1

How can I modify it so that it works in XOJO Version 2021 Release 3?

Thanks.

Lennox

I’m gonna take a stab at this but I don’t think you can “open” a textarea control and put the file contents in there. So maybe something like this?

Var file As FolderItem
Var textInput As TextInputStream
var strFileContent As String

file = SpecialFolder.Desktop.Child(“myFile data”) // opens the file if it is in the specified location

If file <> Nil and file.exists then
  textInput = TextInputStream.Open(file)
  strFileContent = textInput.ReadAll
  self.TextArea1.Text = strFileContent
End If

I have not tested this code, but that should read the contents of the file and then put the content into the textarea control for you.

docu said
TextArea.Open
This item was deprecated in version 2013r1.
Please use TextArea.StyledText.RTFData as a replacement.
https://documentation.xojo.com/api/deprecated/textarea.html.Open
https://documentation.xojo.com/api/text/styledtext.html#styledtext-rtfdata

Please, red the documentation about API2; else, you will get tons of questions 1 or more for each line of code…

Xojo changed dramatically since 2019r1.

You must add a new event named “Opening”,
copy all from “Open” to “Opening”,
delete the event “Open”

That’s a API2 change as mentioned above.

it was a method to open a file in past, not a event

This has nothing to do with events. Open was a now-deprecated method on a TextArea which is not present in a DesktopTextArea.

Thanks for all the responses, I am still using API1 though.
Lennox