Word Processing With Xojo

Hi,

I am trying to add a little word processing capability to my app that allows you to enter text make it bold, underline, and Italics…etc…and then save the file as a RTF. Nothing fancy. I found a small little example app that is perfect. (See Link Below)

http://www.garman.demon.co.uk/rb/Backups/rbTutorialBackup.zip

BUT it is written with Real Studio using Edit Fields instead of text areas. When you load the app, you need to resolve it so that it is compatible with Xojo. Of course when you do that it creates errors when you run it. There are two bugs that are displayed. The first when the FileOpen Code:

[code] Dim f as FolderItem
Dim w as TextWindow

#If TargetWin32 then
f=GetOpenFolderItem(“text;rtf”) //displays open-file dialog
#else //Linux and Macintosh
f=GetOpenFolderItem(“text”)
#endif

If f<>Nil then //the user clicked Open
w=New TextWindow //create new instance of TextWindow
f.OpenStyledEditField w.TextField
w.Document=f //assign f to the Document property
w.Title=f.Name //assign name of f to the Title property of w
w.TextHasChanged=False //reset the TextHasChanged flag
End if[/code]

The line below is where the bug is.

f.OpenStyledEditField w.TextField

The second error is found when you try to save it:

[code] Dim f as FolderItem

If Document = Nil or DisplaySaveDialog then
#If TargetWin32 //if on windows
f=GetSaveFolderItem(“rtf”,FileName) //use rtf fle type
#else //on Linux or Macintosh
f=GetSaveFolderItem(“text”,FileName)
#endif
If f<>Nil then //if the user clicked Save
Title=f.Name //window Title gets the name of the document
Document=f //window property gets the folderitem
End if
End if

If Document<>Nil then
Document.SaveStyledEditField TextField
TextHasChanged=False
End if[/code]

The error is on this line:

Document.SaveStyledEditField TextField

Since the Edit Filed has been replaced with the Text Area, I was wondering if there is a way to change the code so that it works with Xojo’s TextArea?

In the related thread to this project, it was suggested that the control should not be resolved and it will still work, I would rather not have old controls that are depreciated in the project.

As I said, this it a perfect little example of Word Processing. Any help would be greatly appreciated. I think others could use a simple little app like this.

Jim

you link resolves to “example.com

Oops. Here is a better link.

http://www.knightlite.com/xojo/TextEditor.zip

Try these replacements… seems to work
Let Xojo resolve the Editfields first.

    //
    ' DEPRECATED f.OpenStyledEditField w.TextField
    dim t as TextInputStream
    t=TextInputStream.Open(f)
    w.TextField.StyledText.RTFData=t.readall
    t.close
    //
  If Document<>Nil then
    //
    ' DEPRECATED Document.SaveStyledEditField TextField
    dim t as TextOutputStream
    t=TextOutputStream.create(Document)
    t.write TextField.StyledText.RTFData
    t.close
    //
    TextHasChanged=False
  End if

Hi Dave,

That worked great!! Thanks so much for your help. I really appreciate it! It works exactly the way I was hoping. Thanks for taking the time to help me.

No problem… that is what this forum is all about…

James Redway Thank you!